read_scdf | R Documentation |
Use the read_scdf
function to load single-case data csv, excel, or yaml
files.
read_scdf(
file,
cvar = "case",
pvar = "phase",
dvar = "values",
mvar = "mt",
sort_cases = FALSE,
phase_names = NULL,
type = NA,
na = c("", "NA"),
sort.labels = NULL,
phase.names = NULL,
...
)
file |
Either a character string defining the file to be loaded (e.g.
|
cvar |
Sets the variable name of the "case" variable. Defaults to
|
pvar |
Sets the variable name of the "phase" variable. Defaults to |
dvar |
Sets the variable name of the "values" variable. Defaults to |
mvar |
Sets the variable name of the "mt" variable. Defaults to |
sort_cases , sort.labels |
If set TRUE, the resulting list is sorted by label names (alphabetically increasing). |
phase_names , phase.names |
A character vector with phase names. Defaults to the phase names provided in the phase variable. |
type |
Format of the file to be loaded. Either "csv", "xlsx", "xls", "excel", "yml" is possible. By default (NA) the type is extracted from the file extension. |
na |
Character vector of strings to interpret as missing values. |
... |
Further arguments passed to the respective read function. |
Returns a single-case data frame. See scdf
to learn
about the format of these data frames.
Juergen Wilbert
read.table()
, readRDS()
Other io-functions:
convert()
,
write_scdf()
## Read SC-data from a file named "study1.csv" in your working directory
# study1 <- read_scdf("study1.csv")
## Read SC-data from a .csv-file with semicolon as field and comma as decimal separator
# study2 <- read_scdf("study2.csv", sep = ";", dec = ",")
## write_scdf and read_scdf
filename <- file.path(tempdir(), "test.csv")
write_scdf(exampleA1B1A2B2_zvt, filename)
dat <- read_scdf(filename, cvar = "case", pvar = "part", dvar = "zvt", mvar = "day")
res1 <- describe(exampleA1B1A2B2_zvt)$descriptives
res2 <- describe(dat)$descriptives
all.equal(res1,res2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.