Difference between revisions of "OpasnetUtils/Ograph"
From Testiwiki
(copied from op_fi:OpasnetUtils/Ograph) |
(depreciated) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[op_fi:OpasnetUtils/Ograph]] | [[op_fi:OpasnetUtils/Ograph]] | ||
[[Category:OpasnetUtils]] | [[Category:OpasnetUtils]] | ||
+ | [[Category:Code under inspection]] | ||
{{method}} | {{method}} | ||
+ | :'''This code is depreciated. Instead, use | ||
+ | objects.latest("Op_en6007", code_name = "answer") # [[OpasnetUtils/Drafts]] | ||
+ | in your code to fetch official draft objects. | ||
==Kysymys== | ==Kysymys== | ||
Line 10: | Line 14: | ||
<rcode name="answer"> | <rcode name="answer"> | ||
+ | |||
ograph <- function( # Määritellään yleisfunktio peruskuvaajan piirtämiseen. | ograph <- function( # Määritellään yleisfunktio peruskuvaajan piirtämiseen. | ||
ovariable, | ovariable, | ||
x, | x, | ||
− | y = | + | y = character(), |
− | + | type = character(), | |
− | fill = NA, ... | + | other = character(), |
+ | fill = NA, | ||
+ | ... | ||
) { | ) { | ||
− | ovariable <- EvalOutput(ovariable) | + | if(class(ovariable) == "ovariable") { |
− | out <- ggplot( | + | if(nrow(ovariable@output) == 0) ovariable <- EvalOutput(ovariable) |
− | + | data <- ovariable@output | |
− | + | title <- ovariable@name | |
− | + | if(length(y) == 0) y <- paste(title, "Result", sep = "") | |
− | title = | + | } else { |
− | y = paste(unique( | + | data <- ovariable |
− | ) + | + | title <- character() |
− | + | if(length(y) == 0) y <- "Result" | |
+ | } | ||
+ | if(length(type) == 0) { | ||
+ | if("Iter" %in% colnames(data)) type <- geom_boxplot() else type <- geom_bar(stat = "identity") | ||
+ | } | ||
+ | out <- ggplot(data, aes_string(x = x, y = y, fill = fill)) # Määritellään kuvan sarakkeet | ||
+ | out <- out + type | ||
+ | out <- out + theme_grey(base_size=24) # Fontin kokoa suurennetaan | ||
+ | out <- out + labs( | ||
+ | title = title, | ||
+ | y = paste(unique(data[[paste(title, "Yksikkö", sep = "")]]), sep = "", collapse = ", ") | ||
+ | ) | ||
+ | out <- out + theme(axis.text.x = element_text(angle = 90, hjust = 1)) # X-akselin tekstit käännetään niin että mahtuvat | ||
+ | if(length(other) != 0) out <- out + other | ||
return(out) | return(out) | ||
} | } | ||
+ | |||
</rcode> | </rcode> |
Latest revision as of 14:38, 14 November 2013
This page is a method.
The page identifier is Op_en5933 |
---|
Moderator:Nobody (see all) Click here to sign up. |
Give your opinion to the peer rating of the content of this page. |
Upload data
|
- This code is depreciated. Instead, use
objects.latest("Op_en6007", code_name = "answer") # OpasnetUtils/Drafts
in your code to fetch official draft objects.
Kysymys
Millainen on koodi peruskuvaajan piirtämiseen Opasnetissa? Sen on tarkoitus tuottaa yleisesti käytettyjä muuttujien kuvaajia mahdollisimman yksinkertaisella parametrisoinnilla. Mitään erityisiä kommervenkkeja ei tarvita.