Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

load.data

R Utilities: Loading/Reading Data Files using miceadds


Description

The function load.data is a wrapper function for loading or reading data frames or matrices.

The function load.files loads multiple files in a data frame.

Usage

load.data( filename, type=NULL, path=getwd(), load_fun=NULL, spss.default=TRUE, ...)

load.files( files, type=NULL, path=getwd(), ...)

Arguments

filename

Name of the data file (matrix or data frame). This can also be a part of the file name and the most recent file is loaded. filename can also be a vector which strings and a file is loaded which contains all the specified strings.

type

The type of file in which the data frame or matrix should be loaded. This can be Rdata (for R binary format, using load.Rdata2), csv (using utils::read.csv2), csv2 (using utils::read.csv), table (using utils::read.table; the dataset must have the file extension dat or txt), xlsx (using readxl::read_excel; or using the extension xls), or sav (using foreign::read.spss). If an alternative data loading function load_fun is chosen, type must be the file extension.

path

Directory from which the dataset should be loaded. It can also be set to NULL if the absolute path is already included in filename.

load_fun

User-specified loading function

spss.default

Optional logical which is only applied for type="sav" indicating whether the arguments to.data.frame=TRUE and use.value.labels=FALSE are used.

...

Further arguments to be passed to load.Rdata2, utils::read.csv2, utils::read.csv, utils::read.table, readxl::read_excel, foreign::read.spss, or load_fun.

files

Vector of file names

See Also

See also load.Rdata for loading R data frames.

See save.Rdata and save.data for saving/writing R data frames.

Examples

## Not run: 
#############################################################################
# EXAMPLE 1: Toy example
#############################################################################

# load a data frame in the file "data_s3.Rdata" and save this
# as the object "dat.s3"
dat.s3 <- miceadds::load.data( filename="data_s3.Rdata", type="Rdata" )
print(str(dat.s3))

# load text input with base::readLines() function using the 'load_fun' argument
dat <- miceadds::load.data( "my_output_", type="Rout", load_fun=readLines, path=path)

## End(Not run)

miceadds

Some Additional Multiple Imputation Functions, Especially for 'mice'

v3.11-6
GPL (>= 2)
Authors
Alexander Robitzsch [aut,cre] (<https://orcid.org/0000-0002-8226-3132>), Simon Grund [aut] (<https://orcid.org/0000-0002-1290-8986>), Thorsten Henke [ctb]
Initial release
2021-01-21 11:48:47

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.