|
44 | 44 | return(opt) |
45 | 45 | } |
46 | 46 |
|
47 | | -.readDataRegressionAnalyses <- function(dataset, options, jaspResults) { |
48 | | - dataset <- .readDataClassificationRegressionAnalyses(dataset, options) |
49 | | - if (length(unlist(options[["predictors"]])) > 0 && options[["scaleVariables"]]) { |
50 | | - dataset[, options[["predictors"]]] <- .scaleNumericData(dataset[, options[["predictors"]], drop = FALSE]) |
51 | | - } |
| 47 | +.readDataRegressionAnalyses <- function(dataset, options, jaspResults, include_weights = FALSE) { |
| 48 | + dataset <- .readDataClassificationRegressionAnalyses(dataset, options, include_weights) |
52 | 49 | return(dataset) |
53 | 50 | } |
54 | 51 |
|
55 | | -.readDataClassificationRegressionAnalyses <- function(dataset, options) { |
| 52 | +.readDataClassificationRegressionAnalyses <- function(dataset, options, include_weights) { |
56 | 53 |
|
| 54 | + target <- NULL |
| 55 | + weights <- NULL |
57 | 56 | testSetIndicator <- NULL |
58 | | - if (options[["testSetIndicatorVariable"]] != "" && options[["holdoutData"]] == "testSetIndicator") |
59 | | - testSetIndicator <- "testSetIndicatorVariable" |
| 57 | + if (options[["target"]] != "") { |
| 58 | + target <- options[["target"]] |
| 59 | + } |
| 60 | + if (include_weights && options[["weights"]] != "") { |
| 61 | + weights <- options[["weights"]] |
| 62 | + } |
| 63 | + if (options[["testSetIndicatorVariable"]] != "" && options[["holdoutData"]] == "testSetIndicator") { |
| 64 | + testSetIndicator <- options[["testSetIndicatorVariable"]] |
| 65 | + } |
60 | 66 |
|
61 | | - return(.readAndAddCompleteRowIndices(options, c("target", "predictors"), testSetIndicator)) |
| 67 | + predictors <- unlist(options["predictors"]) |
| 68 | + predictors <- predictors[predictors != ""] |
| 69 | + dataset <- jaspBase::excludeNaListwise(dataset, c(target, predictors, weights, testSetIndicator)) |
| 70 | + |
| 71 | + # Scale numeric predictors |
| 72 | + if (length(unlist(options[["predictors"]])) > 0 && options[["scaleVariables"]]) { |
| 73 | + dataset[, options[["predictors"]]] <- .scaleNumericData(dataset[, options[["predictors"]], drop = FALSE]) |
| 74 | + } |
| 75 | + # Make sure the test set indicator is numeric |
| 76 | + if (options[["testSetIndicatorVariable"]] != "" && options[["holdoutData"]] == "testSetIndicator") |
| 77 | + dataset[[options[["testSetIndicatorVariable"]]]] <- as.numeric(dataset[[options[["testSetIndicatorVariable"]]]]) |
| 78 | + |
| 79 | + return(dataset) |
62 | 80 | } |
63 | 81 |
|
64 | 82 | .readAndAddCompleteRowIndices <- function(options, optionNames = NULL, optionNamesAsNumeric = NULL) { |
|
0 commit comments