|
44 | 44 | return(opt) |
45 | 45 | } |
46 | 46 |
|
47 | | -.readDataRegressionAnalyses <- function(dataset, options, jaspResults) { |
48 | | - if (is.null(dataset)) { |
49 | | - dataset <- .readDataClassificationRegressionAnalyses(dataset, options) |
50 | | - } |
51 | | - if (length(unlist(options[["predictors"]])) > 0 && options[["scaleVariables"]]) { |
52 | | - dataset[, options[["predictors"]]] <- .scaleNumericData(dataset[, options[["predictors"]], drop = FALSE]) |
53 | | - } |
| 47 | +.readDataRegressionAnalyses <- function(dataset, options, jaspResults, include_weights = FALSE) { |
| 48 | + dataset <- .readDataClassificationRegressionAnalyses(dataset, options, include_weights) |
54 | 49 | return(dataset) |
55 | 50 | } |
56 | 51 |
|
57 | | -.readDataClassificationRegressionAnalyses <- function(dataset, options) { |
| 52 | +.readDataClassificationRegressionAnalyses <- function(dataset, options, include_weights) { |
58 | 53 |
|
| 54 | + target <- NULL |
| 55 | + weights <- NULL |
59 | 56 | testSetIndicator <- NULL |
60 | | - if (options[["testSetIndicatorVariable"]] != "" && options[["holdoutData"]] == "testSetIndicator") |
61 | | - 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 | + } |
| 66 | + |
| 67 | + predictors <- unlist(options["predictors"]) |
| 68 | + predictors <- predictors[predictors != ""] |
| 69 | + dataset <- jaspBase::excludeNaListwise(dataset, c(target, predictors, weights, testSetIndicator)) |
62 | 70 |
|
63 | | - return(.readAndAddCompleteRowIndices(options, c("target", "predictors"), testSetIndicator)) |
| 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) |
64 | 80 | } |
65 | 81 |
|
66 | 82 | .readAndAddCompleteRowIndices <- function(options, optionNames = NULL, optionNamesAsNumeric = NULL) { |
|
72 | 88 | options[[name2]] <- rep("scale", length(options[[name]])) |
73 | 89 | } |
74 | 90 | dataset <- jaspBase::readDataSetByVariableTypes(options, c(optionNames, optionNamesAsNumeric)) |
75 | | - complete.index <- which(complete.cases(dataset)) |
76 | | - dataset <- na.omit(dataset) |
77 | | - rownames(dataset) <- as.character(complete.index) |
| 91 | + dataset <- jaspBase::excludeNaListwise(dataset, c(options[["target"]], options[["predictors"]])) |
78 | 92 | return(dataset) |
79 | 93 | } |
80 | 94 |
|
|
0 commit comments