rawdata {musclesyneRgies}R Documentation

Import RData or ASCII data into R

Description

Import RData or ASCII data into R

Usage

rawdata(path_cycles = NA, path_emg = NA, header_cycles, header_emg = TRUE)

Arguments

path_cycles

Optional, path where cycle timing files are located

path_emg

Optional, path where raw EMG files are located

header_cycles

Logical, are the cycle files containing a named header (the header is optional)?

header_emg

Logical, are the raw EMG files containing a named header (they should)?

Details

Supported are R lists saved as RData files or tab- or comma-separated files readable through read.table() or read.csv(). The first column of each raw emg file must be time in the same units as those used for the cycle timings (e.g., [s] or [ms]). If reading from RData files, please call cycles CYCLE_TIMES.RData and raw EMG RAW_EMG.RData. Lists must be saved with save().

Value

List of objects of class EMG, each with elements:

Examples

# Load built-in data set
data("RAW_DATA")

# Get current working directory
data_path <- getwd()
data_path <- paste0(data_path, .Platform$file.sep)

# Create two conveniently-named subfolders if they don't already exist
# (if they exist, please make sure they're empty!)
dir.create("cycles", showWarnings = FALSE)
dir.create("emg", showWarnings = FALSE)

# Export ASCII data from built-in data set to the new subfolders
write.table(RAW_DATA[[1]]$cycles,
  file = paste0(data_path, "cycles", .Platform$file.sep, names(RAW_DATA)[1], ".txt"),
  sep = "\t", row.names = FALSE, col.names = FALSE
)
write.table(RAW_DATA[[1]]$emg,
  file = paste0(data_path, "emg", .Platform$file.sep, names(RAW_DATA)[1], ".txt"),
  sep = "\t", row.names = FALSE
)

# Run the function to parse ASCII files into objects of class `EMG`
raw_data_from_files <- rawdata(
  path_cycles = paste0(data_path, "/cycles/"),
  path_emg = paste0(data_path, "/emg/"),
  header_cycles = FALSE
)

# Check data in the new folders if needed before running the following (will delete!)

# Delete folders
unlink("cycles", recursive = TRUE)
unlink("emg", recursive = TRUE)

[Package musclesyneRgies version 1.2.5 Index]