OpasnetUtils/Drafts: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(updated Suomentaja)
Line 15: Line 15:
  objects.latest("Op_en6007", code_name = "answer")
  objects.latest("Op_en6007", code_name = "answer")


<rcode name="answer" embed=1>
<rcode name="answer" embed=1 store=1>


library(OpasnetUtils)
library(OpasnetUtils)
#################### Perus-ggplot ovariableille
oggplot <- function(
ova, #ovariable to be plotted
x, # index for x axis
weight = NULL, # weights to be used (ovariable result by default)
fill = NULL, # index for stack colour
labs.title = NULL, # graph main title
labs.x = NULL, # x axis label
labs.y = NULL, # y axis label
base_size = BS, # base_size for font
turnx = FALSE
) {
if(is.null(weight)) weight <- paste(ova@name, "Result", sep = "")
plo <- ggplot(ova@output) +
geom_bar(
data = subset(ova@output, ova@output[[rescol]] > 0),
aes_string(x = x, weight = weight, fill = fill),
position="stack"
) +
geom_bar(
data = subset(ova@output, ova@output[[rescol]] < 0),
aes_string(x = x, weight = weight, fill = fill),
position="stack"
) +
theme_gray(base_size = base_size) +
labs(
title = labs.title,
y = labs.y,
x = labs.x
)
if(any(ova@output[[rescol]] < 0)) plo <- plo + geom_hline(aes(yintercept=0))
if(turnx) plo <- plo + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) # Turn text and adjust to right
return(plo)
}


################## Suomentaja
################## Suomentaja
Line 118: Line 156:
}
}


colnames(d)[colnames(d) == "Decision maker"] <- “Päätöksentekijä”
colnames(d)[colnames(d) == "Decision maker"] <- "Päätöksentekijä"
colnames(d)[colnames(d) == "Decision"] <- “Päätös”
colnames(d)[colnames(d) == "Decision"] <- "Päätös"
colnames(d)[colnames(d) == "Option"] <- “Vaihtoehto”
colnames(d)[colnames(d) == "Option"] <- "Vaihtoehto"
colnames(d)[colnames(d) == "Building"] <- “Rakennus”
colnames(d)[colnames(d) == "Building"] <- "Rakennus"
colnames(d)[colnames(d) == "Efficiency"] <- “Tehokkuus”
colnames(d)[colnames(d) == "Efficiency"] <- "Tehokkuus"
colnames(d)[colnames(d) == "Renovation"] <- “Korjaukset”
colnames(d)[colnames(d) == "Renovation"] <- "Korjaukset"
colnames(d)[colnames(d) == “Plant”] <- “Voimala”
colnames(d)[colnames(d) == "Plant"] <- "Voimala"
colnames(d)[colnames(d) == “Fuel”] <- “Polttoaine”
colnames(d)[colnames(d) == "Fuel"] <- "Polttoaine"
return(d)
return(d)
Line 874: Line 912:


objects.store(ograph, collapsemarg, MyPointKML, ova2spat, MyRmap, MyPlotKML, truncateIndex, findrest,  
objects.store(ograph, collapsemarg, MyPointKML, ova2spat, MyRmap, MyPlotKML, truncateIndex, findrest,  
timing, makeTimeline, timepoints, ana2ova, orbind2)
timing, makeTimeline, timepoints, ana2ova, orbind2, oggplot)


cat(paste("The following objects are stored: ograph, collapsemarg, MyPointKML, ova2spat, MyRmap, MyPlotKML,",
cat(paste("The following objects are stored: ograph, collapsemarg, MyPointKML, ova2spat, MyRmap, MyPlotKML,",
"truncateIndex, findrest, timing, makeTimeline, timepoints, ana2ova, orbind2.\n"))
"truncateIndex, findrest, timing, makeTimeline, timepoints, ana2ova, orbind2, oggplot.\n"))
</rcode>
</rcode>



Revision as of 13:54, 14 August 2015



Question

Which functions are so useful that they should be taken into OpasnetUtils package? This page contains draft function which will be included when they are good enough and found important.

Answer

Call the objects stored by this code from another rode with this command:

objects.latest("Op_en6007", code_name = "answer")

+ Show code

See also

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>