incadata (version 0.5.3)

use_incadata: Use incadata from file or dataframe df

Description

Read in a file (locally) or use global object named df (on INCA) and coerce to incadata-object.

Usage

use_incadata(file, cache = TRUE, sep = ";", dec = ",", ...)

Arguments

file

file name as character (ignored if called from INCA)

cache

use cache to speed up the loading (see section: "cache_date"). TRUE by default

sep, dec

arguments passed to read.csv2

...

arguments passed to as.incadata.

Value

An incadata object containing a representation of the data in the file (or df).

Cache

To process all data through as.incadata can be time consuming for large data sets. It is therefore advised to use caching (argument cache = TRUE) to avoid unnecessary processing of already formatted data. If cache = TRUE, the function will read and process the data only the first time (or if the original data is later changed). A processed and cached version of the data is saved with suffix ".rds". The cached version is always compared to the original file by its MD5 sum and is updated if needed.

Examples

Run this code
# NOT RUN {
# Create a csv file with example data in a temporary directory
fl <- tempfile("ex_data", fileext = ".csv2")
write.csv2(incadata::ex_data, fl)

# First time the file is read from csv2
use_incadata(fl)
dir(tempdir) # a cache file is saved along the original csv2-file
use_incadata(fl) # Next time file loaded from cache
# }

Run the code above in your browser using DataCamp Workspace