Merge branch 'unstable'

This commit is contained in:
hollorol 2018-05-08 14:09:24 +02:00
commit 486dea29b8
5 changed files with 31 additions and 5 deletions

View File

@ -16,7 +16,8 @@ Imports:
graphics,
Rcpp,
magrittr,
dplyr
dplyr,
ggplot2
LinkingTo: Rcpp
Maintainer: Roland Hollo's <hollorol@gmail.com>
RoxygenNote: 6.0.1

View File

@ -19,6 +19,7 @@ export(spinupMuso)
export(supportedMuso)
export(updateMusoMapping)
import(dplyr)
import(ggplot2)
import(grDevices)
import(graphics)
import(magrittr)

View File

@ -17,11 +17,13 @@
#' @import dplyr
#' @import graphics
#' @import grDevices
#' @import ggplot2
#' @export
musoSensi <- function(monteCarloFile = NULL,
parameters,
parameters=NULL,
settings = NULL,
parametersFromFile=FALSE,
inputDir = "./",
outLoc = "./calib",
iterations = 30,
@ -30,7 +32,19 @@ musoSensi <- function(monteCarloFile = NULL,
fun = mean,
varIndex = 1,
outputFile = "sensitivity.csv",
plotName = "sensitivity.jpg"){
plotName = "sensitivity.png",
plotTitle = "Sensitivity",
dpi=300){
if(is.null(parameters)){
parameters <- read.csv("parameters.csv")
} else {
if(parametersFromFile){
parameters <- read.csv(parameters,stringsAsFactors=FALSE)
} else {
parameters <- parameters
}
}
doSensi <- function(M){
npar <- ncol(M)-1
@ -47,9 +61,19 @@ musoSensi <- function(monteCarloFile = NULL,
for(i in 1:npar){
S[i] <- ((w[i]^2*Sv[i]^2)/overalVar)*100
}
S <- round(S)
names(S)<-varNames
write.csv(file = outputFile, x = S)
barplot(S,las=2)
sensiPlot <- ggplot(data.frame(name=varNames,y=S/100),aes(x=name,y=y))+
geom_bar(stat = 'identity')+
theme(axis.text.x = element_text(angle = 45, hjust = 1))+
xlab(NULL)+
ylab(NULL)+
ggtitle("Sensitivity")+
scale_y_continuous(labels = scales::percent,limits=c(0,1))
print(sensiPlot)
ggsave(plotName,dpi=dpi)
return(S)
}

Binary file not shown.

View File

@ -7,7 +7,7 @@
musoSensi(monteCarloFile = NULL, parameters, settings = NULL,
inputDir = "./", outLoc = "./calib", iterations = 30,
preTag = "mont-", outputType = "moreCsv", fun = mean, varIndex = 1,
outputFile = "sensitivity.csv", plotName = "sensitivity.jpg")
outputFile = "sensitivity.csv", plotName = "sensitivity")
}
\arguments{
\item{monteCarloFile}{If you run musoMonte function previously, you did not have to rerun the monteCarlo, just provide the preservedEpc.csv file with its path. If you do not set this parameter, musoSensi will fun the musoMonte function to get all of the information.}