implementing ggplot
This commit is contained in:
parent
b6b700a27a
commit
928ec504d6
@ -16,7 +16,8 @@ Imports:
|
|||||||
graphics,
|
graphics,
|
||||||
Rcpp,
|
Rcpp,
|
||||||
magrittr,
|
magrittr,
|
||||||
dplyr
|
dplyr,
|
||||||
|
ggplot2
|
||||||
LinkingTo: Rcpp
|
LinkingTo: Rcpp
|
||||||
Maintainer: Roland Hollo's <hollorol@gmail.com>
|
Maintainer: Roland Hollo's <hollorol@gmail.com>
|
||||||
RoxygenNote: 6.0.1
|
RoxygenNote: 6.0.1
|
||||||
|
|||||||
@ -19,6 +19,7 @@ export(spinupMuso)
|
|||||||
export(supportedMuso)
|
export(supportedMuso)
|
||||||
export(updateMusoMapping)
|
export(updateMusoMapping)
|
||||||
import(dplyr)
|
import(dplyr)
|
||||||
|
import(ggplot2)
|
||||||
import(grDevices)
|
import(grDevices)
|
||||||
import(graphics)
|
import(graphics)
|
||||||
import(magrittr)
|
import(magrittr)
|
||||||
|
|||||||
@ -17,11 +17,13 @@
|
|||||||
#' @import dplyr
|
#' @import dplyr
|
||||||
#' @import graphics
|
#' @import graphics
|
||||||
#' @import grDevices
|
#' @import grDevices
|
||||||
|
#' @import ggplot2
|
||||||
#' @export
|
#' @export
|
||||||
|
|
||||||
musoSensi <- function(monteCarloFile = NULL,
|
musoSensi <- function(monteCarloFile = NULL,
|
||||||
parameters,
|
parameters=NULL,
|
||||||
settings = NULL,
|
settings = NULL,
|
||||||
|
parametersFromFile=FALSE,
|
||||||
inputDir = "./",
|
inputDir = "./",
|
||||||
outLoc = "./calib",
|
outLoc = "./calib",
|
||||||
iterations = 30,
|
iterations = 30,
|
||||||
@ -30,7 +32,19 @@ musoSensi <- function(monteCarloFile = NULL,
|
|||||||
fun = mean,
|
fun = mean,
|
||||||
varIndex = 1,
|
varIndex = 1,
|
||||||
outputFile = "sensitivity.csv",
|
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){
|
doSensi <- function(M){
|
||||||
npar <- ncol(M)-1
|
npar <- ncol(M)-1
|
||||||
@ -47,9 +61,19 @@ musoSensi <- function(monteCarloFile = NULL,
|
|||||||
for(i in 1:npar){
|
for(i in 1:npar){
|
||||||
S[i] <- ((w[i]^2*Sv[i]^2)/overalVar)*100
|
S[i] <- ((w[i]^2*Sv[i]^2)/overalVar)*100
|
||||||
}
|
}
|
||||||
|
S <- round(S)
|
||||||
names(S)<-varNames
|
names(S)<-varNames
|
||||||
write.csv(file = outputFile, x = S)
|
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)
|
return(S)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -7,7 +7,7 @@
|
|||||||
musoSensi(monteCarloFile = NULL, parameters, settings = NULL,
|
musoSensi(monteCarloFile = NULL, parameters, settings = NULL,
|
||||||
inputDir = "./", outLoc = "./calib", iterations = 30,
|
inputDir = "./", outLoc = "./calib", iterations = 30,
|
||||||
preTag = "mont-", outputType = "moreCsv", fun = mean, varIndex = 1,
|
preTag = "mont-", outputType = "moreCsv", fun = mean, varIndex = 1,
|
||||||
outputFile = "sensitivity.csv", plotName = "sensitivity.jpg")
|
outputFile = "sensitivity.csv", plotName = "sensitivity")
|
||||||
}
|
}
|
||||||
\arguments{
|
\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.}
|
\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.}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user