R Language Reproducible R Data reproducibility


dput() and dget()

The easiest way to share a (preferable small) data frame is to use a basic function dput(). It will export an R object in a plain text form.

Note: Before making the example data below, make sure you're in an empty folder you can write to. Run getwd() and read ?setwd if you need to change folders.

dput(mtcars, file = 'df.txt')

Then, anyone can load the precise R object to their GlobalEnvironment using the dget() function.

df <- dget('df.txt')

For larger R objects, there are a number of ways of saving them reproducibly. See Input and output .