diff --git a/R/commonDiscoverDistributions.R b/R/commonDiscoverDistributions.R index 89d7f3dd..92246c3b 100644 --- a/R/commonDiscoverDistributions.R +++ b/R/commonDiscoverDistributions.R @@ -17,24 +17,22 @@ ### Summary stats for distributions module ---- .simulateData <- function(jaspResults, options, as = "scale", sampleSizeName = "n"){ - if(is.null(jaspResults[['simdata']])){ + if (is.null(jaspResults[["sampleColumn"]])) { args <- c(options[['pars']], sampleSize = options[['sampleSize']]) names(args)[names(args) == "sampleSize"] <- sampleSizeName sample <- do.call(options[['rFun']], args) - jaspResults[['simdata']] <- createJaspState(sample) - jaspResults[['simdata']]$dependOn(c("newVariableName", "simulateNow")) - if(options[["newVariableName"]] != "") + if (options[["newVariableName"]] != "") { - jaspResults[['sampleColumn']] <- createJaspColumn(options[["newVariableName"]]) - + jaspResults[['sampleColumn']] <- createJaspColumn(options[["newVariableName"]], dependencies = c("newVariableName", "simulateNow")) + didItWork <- switch(as, scale= jaspResults[['sampleColumn']]$setScale( sample), ordinal=jaspResults[['sampleColumn']]$setOrdinal(sample), jaspResults[['sampleColumn']]$setNominal(sample)) - if(!didItWork) + if(!didItWork) jaspResults[['sampleColumnError']] <- createJaspHtml(text=gettextf("Could not write to column '%s', probably because it wasn't created by this analysis", options[["newVariableName"]]), elementType="errorMsg", dependencies="newVariableName") } }