Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vandenman committed Sep 20, 2024
1 parent f7b0dff commit b04c89a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
10 changes: 3 additions & 7 deletions R/dataset.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
loadCorrectDataset <- function(x, nrows = -1) {
loadCorrectDataset <- function(x) {
if (is.matrix(x) || is.data.frame(x)) {
return(x)
} else if (is.character(x)) {
Expand All @@ -8,10 +8,7 @@ loadCorrectDataset <- function(x, nrows = -1) {

# check if it's a path to a file
if (file.exists(x)) {
dataset <- utils::read.csv(x, header = TRUE, check.names = FALSE, stringsAsFactors = TRUE, nrows = nrows)
if (nrows == 0)
return(dataset[0, , drop = FALSE])
return(dataset)
return(utils::read.csv(x, header = TRUE, check.names = FALSE, stringsAsFactors = TRUE, nrows = nrows))
}

# check if it's a name of a JASP dataset
Expand All @@ -27,8 +24,7 @@ loadCorrectDataset <- function(x, nrows = -1) {
if (length(match) > 1) {
warning("Multiple datasets exists with the same name, choosing '", datasets[match[1]], "'")
}
return(data.table::fread(fullPath, header = TRUE, check.names = FALSE, data.table = FALSE,
nrows = if (nrows == -1) Inf else nrows))
return(data.table::fread(fullPath, header = TRUE, check.names = FALSE, data.table = FALSE))
}
allDatasets <- c(allDatasets, basename(datasets))

Expand Down
3 changes: 1 addition & 2 deletions R/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ initAnalysisRuntime <- function(dataset, options, makeTests, ...) {
# first we reinstall any changed modules in the personal library
reinstallChangedModules()

preloadDataset(dataset, options)
# dataset to be found in the analysis when it needs to be read
# .setInternal("dataset", dataset)
preloadDataset(dataset, options)

# prevent the results from being translated (unless the user explicitly wants to)
Sys.setenv(LANG = getPkgOption("language"))
Expand Down

0 comments on commit b04c89a

Please sign in to comment.