prep_exp_data {forceplate} | R Documentation |
Prepare Experimental Data
Description
Processing the experimental data by removing unnecessary variables and removing rows in the data
that are not trials. The output is a data.table
.
Usage
prep_exp_data(
filenames,
na.strings = c(",,", "[]", "None"),
excl.vars = NULL,
blacklist.vars = NULL,
whitelist.vars = NULL,
sort = TRUE
)
Arguments
filenames |
A (vector of) character(s) providing the raw experimental data file name(s). Files can be .txt, .csv, or any common type. |
na.strings |
A (vector of) character(s) naming the strings that should be treated as NA. |
excl.vars |
A (vector of) number(s) or character(s) providing the column number(s) or name(s)
of the data which will be used for spotting rows that are not trials, that is, rows that are
NA in each of the columns |
blacklist.vars |
A (vector of) number(s) or character(s) providing the column number(s) or name(s) of variables to be deleted from the data. NULL means no variable will be deleted. |
whitelist.vars |
A (vector of) number(s) or character(s) providing the column number(s) or name(s) of variables to be kept in the data. All others will be deleted. NULL means all variables will be kept. |
sort |
TRUE or FALSE. If TRUE the data will be sorted by subject number and block number. |
Value
A data.table
of the class exp.prep
.
Author(s)
Raphael Hartmann & Anton Koger
Examples
# Using example data from github which requires internet
if (curl::has_internet()) {
url <- paste0("https://raw.githubusercontent.com/RaphaelHartmann/forceplate/",
"main/data/subj13_exp_data.csv")
# Safe download, handling potential errors
tryCatch({
filenames <- tempfile(pattern = c("subj13_exp_data"), tmpdir = tempdir(), fileext = ".csv")
download.file(url, filenames)
# prepare experimental data
exp.dt <- prep_exp_data(filenames = filenames, excl.vars = 2:5)
# Clean up
unlink(filenames)
}, error = function(e) {
message("Failed to download data: ", e$message)
})
}