R: Use incadata from file or dataframe df

use_incadata {incadata} | R Documentation

## 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" below)
`sep, dec` | arguments passed to `read.csv2`
`...` | arguments passed to `as.incadata`.

### Value

object returned by `as.incadata`

### 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 always updated if needed.

### Examples

    ## 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

    ## End(Not run)

[Package incadata version 0.6.4 Index]