tidyr 0.2.0 (and reshape2 1.4.1)
tidyr 0.2.0 is now available on CRAN. tidyr makes it easy to “tidy” your data, storing it in a consistent form so that it’s easy to manipulate, visualise and model. Tidy data has variables in columns and observations in rows, and is described in more detail in the tidy data vignette. Install tidyr with:
There are three important additions to tidyr 0.2.0:
expand()is a wrapper around
expand.grid()that allows you to generate all possible combinations of two or more variables. In conjunction with
dplyr::left_join(), this makes it easy to fill in missing rows of data.
sales <- dplyr::data_frame( year = rep(c(2012, 2013), c(4, 2)), quarter = c(1, 2, 3, 4, 2, 3), sales = sample(6) * 100 ) # Missing sales data for 2013 Q1 & Q4 sales #> Source: local data frame [6 x 3] #> #> year quarter sales #> 1 2012 1 400 #>…
View original post 480 more words