knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

datafile

Build Status

The datafile package is build around the philosophy that data should be separated from code. This means that data is always written to a different location (directory) than your current working directory, which contains the code.

Installation

You can install the github version of this package with

devtools::install_github("jspijker/datafile")

Basic Example

In this example we create a 'data' directory using datafileInit().The default location is to create a data directory under the current working directory. You can create this data directory at any location and for reproducibility we use the system temporary directory. Then we create some variable x. Using saveRDS and datafile we save it to disk. The final RDS file is now saved to /tmp/Rtmp[.....]/data/x.rds.

library(datafile)
datafileInit(basedir=tempdir()) 
x<-rnorm(10)
saveRDS(x,datafile("x.rds"))

To retrieve the rds file, we use:

x<-readRDS(datafile("x.rds"))

If datafile is to much typing for you, you can use the alias dfn(), which stands for 'data file name'.

x<-readRDS(dfn("x.rds"))

Please see the vignette for more examples how to use this package()

unlink("./data/",recursive=TRUE)


jspijker/datafile documentation built on Nov. 8, 2024, 6:47 p.m.