Making base R objects “tidy”
The tidyverse
packages (including dplyr
, tidyr
, and ggplot2
) have had a huge influence on data processing and analysis in R, through their application of the “tidy” way of working. In essence, “tidy” means that data is kept in a particular format, in which each row holds a single observation of some variable , and columns specify the variables recorded and contain all values for those variables across all observations. Such a structure means that analytical steps have predictable input and output and can be built into complex pipelines with relative ease. Most base R objects are not tidy, and it can often take significant programming work to extract the parts that are needed downstream. In this recipe, we will look at some functions to automatically convert some common base R objects into a tidy dataframe.
Getting ready
We’ll need tidyr
, broom,
and also biobroom
from Bioconductor. For data, we’...