as.data.frame.secuTrialdata: as.data.frame method for secuTrialdata objects Make the data...

View source: R/asdataframe.R

as.data.frame.secuTrialdataR Documentation

as.data.frame method for secuTrialdata objects Make the data from the exports more easily accessible by placing them in another environment (e.g. place them in the global environment (.GlobalEnv) and you can reference them without referring to the secuTrialdata object anymore. Ie. they become regular data.frames).

Description

as.data.frame method for secuTrialdata objects Make the data from the exports more easily accessible by placing them in another environment (e.g. place them in the global environment (.GlobalEnv) and you can reference them without referring to the secuTrialdata object anymore. Ie. they become regular data.frames).

Usage

## S3 method for class 'secuTrialdata'
as.data.frame(
  x,
  ...,
  envir,
  data.frames = NULL,
  meta = FALSE,
  regex = NULL,
  rep = ""
)

Arguments

x

secuTrialdata object

...

further parameters

envir

environment in which to put the data (e.g. .GlobalEnv)

data.frames

character vector of data.frame names to turn into data.frames. If the vector is named,data.frames will be renamed into the non-empty names(data.frames)

meta

logical should metadata be returned

regex

regex syntax to remove from names

rep

replacement for regex

Details

envir must be specifically defined. For simplicity, .GlobalEnv would probably be the easiest (assigning it to another environment would still entail referring to that environment).

Value

each data.frame in the secuTrialdata object is saved to it's own data.frame in the designated environment

Examples

# prepare path to example export
export_location <- system.file("extdata", "sT_exports", "lnames",
                               "s_export_CSV-xls_CTU05_long_ref_miss_en_utf8.zip",
                               package = "secuTrialR")
# load all export data
sT_export <- read_secuTrial_raw(data_dir = export_location)
# add files to a new environment called env1
env1 <- new.env()
as.data.frame(sT_export, envir = env1)
# add files to a new environment called env2, removing the project name from
# the file names
env2 <- new.env()
as.data.frame(sT_export, regex = "ctu05", envir = env2)
# add files to a new environment called env3, renaming files in data.frames
env3 <- new.env()
as.data.frame(sT_export, data.frames = c("allmedications" = "ctu05allmedi", "ctu05baseline"),
              envir = env3)

secuTrialR documentation built on March 7, 2023, 5:35 p.m.