Automatic Conversion of Tables to LongForm Dataframes

TableToLongForm automatically converts hierarchical Tables intended for a human reader into a simple LongForm dataframe that is machine readable, making it easier to access and use the data for analysis. It does this by recognising positional cues present in the hierarchical Table (which would normally be interpreted visually by the human brain) to decompose, then reconstruct the data into a LongForm dataframe. The article motivates the benefit of such a conversion with an example Table, followed by a short user manual, which includes a comparison between the simple one argument call to TableToLongForm, with code for an equivalent manual conversion. The article then explores the types of Tables the package can convert by providing a gallery of all recognised patterns. It finishes with a discussion of available diagnostic methods and future work.

Jimmy Oh

CRAN packages used

TableToLongForm, reshape2, plyr

CRAN Task Views implied by cited packages


Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".


For attribution, please cite this work as

Oh, "The R Journal: Automatic Conversion of Tables to LongForm Dataframes", The R Journal, 2014

BibTeX citation

  author = {Oh, Jimmy},
  title = {The R Journal: Automatic Conversion of Tables to LongForm Dataframes},
  journal = {The R Journal},
  year = {2014},
  note = {},
  doi = {10.32614/RJ-2014-021},
  volume = {6},
  issue = {2},
  issn = {2073-4859},
  pages = {16-26}