# Using example data from GitHub which requires internet
# takes longer than 5 seconds
if (curl::has_internet()) {
url <- paste0("https://raw.githubusercontent.com/RaphaelHartmann/forceplate/",
"main/data/subj013_block001.txt")
# Safe download, handling potential errors
tryCatch({
filenames <- tempfile(pattern = c("subj013_block001_"),
tmpdir = tempdir(), fileext = ".txt")
download.file(url, filenames)
# segment raw text file from Bioware
fp.dt <- segment_fp_data(filenames = filenames, n.trials = 80, baseline.trigger = 128,
baseline.intv = c(0, 215), start.trigger = 128,
stimulus.trigger.list = c(1, 2, 4, 8),
response.trigger.list = c(32, 64),
cond.trigger.list = list(stimulus = c(1, 2, 4, 8),
correctness = c(32, 64)),
control = list(prepend.ms = 0))
# Clean up
unlink(filenames)
}, error = function(e) {
message("Failed to download data: ", e$message)
})
}
Run the code above in your browser using DataLab