Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

by Andrie de Vries

Back in 2011, I asked a question on StackOverflow: “How to make a great R reproducible example?“.

This question attracted some great answers, including answers by Hadley Wickham and Joris Meys (co-author of R for Dummies).

In June of this year Tyler Rinker added a new answer. Tyler published the wakefield package.  In his own words:

I am developing the wakefield package to address this need to quickly share reproducible data, sometimes dput() works fine for smaller data sets but many of the problems we deal with are much larger, sharing such a large data set via dput() is impractical.

I think it is a brilliant idea to create a package that allows you to easily create data with a specified structure.

The package has some very clever ideas.  It contains functions that “knows” about certain data types, e.g. age() generates age ranges and coin() generates a bernoulli sample, to name just a few. You can also specify correlation between variables – a helpful feature if you want to demonstrate a specific statistical model.

The package is not yet on CRAN, but is extensively documented at github.

wakefield is designed to quickly generate random data sets. The user passes n (number of rows) and predefined vectors to the r_data_frame function to produce a dplyr::tbl_df object.

Example

Here is an example from the documentation (modified only very slightly):

This produces the following plot. Notice the correlation in the data – people with high initial grades tend to maintain high grades over time, and vice versa.

Installation and more examples

To install the package, uncomment the first two lines of code and try the examples: