readSC: Read single-case data from files

Description Usage Arguments Value Author(s) See Also Examples

View source: R/readSC.R

Description

Use the readSC function to import single-case data from structured .csv or the readSC.excel function for importing excel files.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
readSC(
  filename = NULL,
  data = NULL,
  sep = ",",
  dec = ".",
  sort.labels = FALSE,
  cvar = "case",
  pvar = "phase",
  dvar = "values",
  mvar = "mt",
  phase.names = NULL,
  type = "csv",
  ...
)

readSC.excel(...)

Arguments

filename

A character string defining the file to be imported (e.g. "SC_Anita.csv". If filename is left empty a dialog box for choosing will be opened.

data

A data frame. As an alternative to filname a dataframe could be directly provided.

sep

The field separator string. Values within rows have to be separated by this string. Default is sep = ",".

dec

The string used for decimal points in the file. Must be a single character. Default is dec = "."

sort.labels

If set TRUE, the resulting list is sorted by label names (alphabetically increasing).

cvar

Sets the variable name of the "case" variable. Deafults to "case".

pvar

Sets the variable name of the "phase" variable. Deafults to "phase".

dvar

Sets the variable name of the "values" variable. Deafults to "values".

mvar

Sets the variable name of the "mt" variable. Deafults to "mt".

phase.names

A character vector with phase names. Deafults to the phase names provided in the phase variable.

type

Format of the file to be imported. Either "csv" or "excel" is possible.

...

Further arguments passed to the read.table command.

Value

Returns a single-case data frame. See scdf to learn about the format of these data frames.

Author(s)

Juergen Wilbert

See Also

read.table, writeSC, scdf, readRDS

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Read SC-data from a file named "study1.csv" in your working directory
# study1 <- readSC("study1.csv")

## Read SC-data from a .csv-file with semicolon as field and comma as decimal separator
# study2 <- readSC("study2.csv", sep = ";", dec = ",")

## writeSc and readSC
filename <- file.path(tempdir(),"test.csv")
writeSC(exampleA1B1A2B2_zvt, filename)
dat <- readSC(filename, cvar = "case", pvar = "part", dvar = "zvt", mvar = "day")
res1 <- describeSC(exampleA1B1A2B2_zvt)$descriptives
res2 <- describeSC(dat)$descriptives
identical(res1,res2)

scan documentation built on Feb. 12, 2021, 3:01 a.m.