#' Launch analysis of interest (Validity, reliability or MAU - SAU differences)
#'
#' @param D Datas
#' @param DDiff Diff MAU - SAU of Datas
#' @param Ref$Name System of reference for machine
#' @param Ref$NameToRead System of reference for human eyes
#' @param Ref$PARNPAR PAR or NPAR to look at this time (reference)
#' @param ToComp$Name System to compare for machine
#' @param ToComp$NameToRead System to compare for human eyes
#' @param ToComp$PARNPAR PAR or NPAR to look at this time (to compare)
#' @param Base$PARNPAR PAR or NPAR to use in basic way
#' @param Base$App The app to use to save MAU - SAU differences
#' @param Base$Rep The rep to use in basic way
#' @param Ref$Name System of reference for machine
#' @param Flag$Manip Current Manip
#' @param Flag$Angles TRUE if angles are recorded
#' @param Flag$Analysis The analyse to conduct
#' @param Flag$qqplot TRUE to print qqplot of each variable
#' @param Var$Variables Variables to analize
#' @param Var$VariablesUnit Units of variables to analize
#' @param Var$Angles Angles to analize
#' @param Var$AnglesNames Names of angles to analize
#' @param Var$AnglesParameters Parameters of angles to look at
#' @param Var$AnglesParametersNames Names of parameters of angles to look at
#' @param Var$AnglesUnit Unit of angles to analize
#'
#' @return FALSE Reset Flag$LaunchAnalysis
#'
#' @export
LaunchAnalysis <- function (
D
, DDiff
, Ref
, ToComp
, Base
, Flag
, Var
) {
#################
#Add variables names
Var$VariablesNames <- Var$Variables
if (Flag$Angles) {
#Compute every variables names for humain reading
#All parameters names for each angle name
for (iAnglesNames in 1:length(Var$AnglesNames)){
for (iAnglesParametersNames in 1:length(Var$AnglesParametersNames)){
newVariableName <- paste(
Var$AnglesParametersNames[iAnglesParametersNames]
, " "
, Var$AnglesNames[iAnglesNames]
, sep = "")
Var$VariablesNames <- c(Var$VariablesNames,newVariableName)
}
}
#Compute every variables names for machine
#All parameters for each angle
for (iAngles in 1:length(Var$Angles)){
for (iAnglesParameters in 1:length(Var$AnglesParameters)){
newVariable <- paste(
Var$Angles[iAngles]
, "_"
, Var$AnglesParameters[iAnglesParameters]
, sep = "")
Var$Variables <- c(Var$Variables,newVariable)
Var$VariablesUnit <- c(Var$VariablesUnit, Var$AnglesUnit)
}
}
}
#Security
#cat(paste("\n", Var$Variables, "\n\n")) #disp variables in console
if (length(Var$Variables) != length(Var$VariablesNames)) {
stop("Error : length(Var$Variables) <> length(Var$VariablesNames) in LaunchAnalysis.R")
}
if (length(Var$Variables) != length(Var$VariablesUnit)) {
stop("Error : length(Var$Variables) <> length(Var$VariablesUnit) in LaunchAnalysis.R")
}
#################
#For each variable, launch programm of interest
for (iVariables in 1:length(Var$Variables)) {
#Get name of current variable and other variables of interest
V <- Var$Variables [iVariables]
VT <- Var$VariablesNames [iVariables]
U <- "%"
RefT <- Ref$NameToRead
ToCompT <- ToComp$NameToRead
UnitCurr <- Var$VariablesUnit[iVariables]
#################
if (Flag$Analysis == "Validity") {
#Set some variables of interest
DRef <- subset(D, App == Ref$Name & (PAR_NPAR == Ref$PARNPAR[1] | PAR_NPAR == Ref$PARNPAR[2]))[,V]
DToComp <- subset(D, App == ToComp$Name & (PAR_NPAR == ToComp$PARNPAR[1] | PAR_NPAR == ToComp$PARNPAR[2]))[,V]
Cond <- paste(RefT, " VS ", ToCompT)
#Lauch comparison 1/1
PlotVar(DRef, DToComp, U, RefT, ToCompT, Cond, V, VT, UnitCurr)
}
#################
#2 -> Reliability of system (R2 VS R1)
if (Flag$Analysis == "Reliability") {
#Set some variables of interest
DRef = subset(D, App == Base$App & (Rep == Ref$Name[1] | Rep == Ref$Name[2]) & (PAR_NPAR == Ref$PARNPAR[1] | PAR_NPAR == Ref$PARNPAR[2]))[,V]
DToComp = subset(D, App == Base$App & (Rep == ToComp$Name[1] | Rep == ToComp$Name[2]) & (PAR_NPAR == ToComp$PARNPAR[1] | PAR_NPAR == ToComp$PARNPAR[2]))[,V]
Cond <- paste(Base$App, ToCompT, "VS", RefT)
Dif = DRef - DToComp
Sum = (DRef + DToComp) / 2
regression = lm(Dif ~ Sum)
DRef = regression$residuals + DToComp
#Lauch comparison 1/1
PlotVar(DRef, DToComp, U, RefT, ToCompT, Cond, V, VT, UnitCurr)
}
#################
#3 -> Influence of load (Loaded VS Control)
if (Flag$Analysis == "Loading") {
#Set some variables of interest
SauMau = "MAU - SAU"
DRef = subset(DDiff, App == Base$App & Rep == Ref$Name & (PAR_NPAR == Ref$PARNPAR[1] | PAR_NPAR == Ref$PARNPAR[2]))[,V]
DToComp = subset(DDiff, App == Base$App & Rep == ToComp$Name & (PAR_NPAR == ToComp$PARNPAR[1] | PAR_NPAR == ToComp$PARNPAR[2]))[,V]
Cond <- paste(RefT, " VS ", ToCompT, " (", SauMau, ")", sep ="")
#Launch comparison 1/2
PlotDiff(DRef, DToComp, U, RefT, ToCompT, Cond, V, VT, UnitCurr, Flag$qqplot)
#Get name of current variable and other variables of interest
RefT <- "PANU"
RefTUnit <- "1"
ToCompT <- V
SauMau = "MAU - SAU"
DRef = subset(DDiff, App == Base$App & Rep == Base$Rep & PAR_NPAR == Base$PARNPAR)[,RefT]
DToComp = subset(DDiff, App == Base$App & Rep == Base$Rep & PAR_NPAR == Base$PARNPAR)[,ToCompT]
ToCompT <- VT
Cond <- paste(ToCompT, " VS ", RefT, " (", SauMau, ") ", Base$App, sep ="")
#Launch comparison 2/2
PlotCor(DRef, DToComp, U, RefT, ToCompT, Cond, V, VT, UnitCurr, RefTUnit)
}
}
cat(rep("\n\n##########\n\n")) #split console output
return(FALSE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.