atorus-research / Tplyr

Home Page:https://atorus-research.github.io/Tplyr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Collapse row labels into one column

mstackhouse opened this issue · comments

Currently row labels output as separate variables, with the exception of nested count layers which can collapse the outer variable into the inner variable, and indent the inner variable's text.

Many organizations' standards collapse row labels into a single column. The basic flow there would be:

  • Grab the distinct set of row labels you want to nest as a dataframe, set a sort variable to 0
    • Preserve the sorting variable already available in Tplyr - so you actually might want to group by the row labes and then use like head(1) instead
  • From the original data frame, set that sort variable to 1
  • Stack them together
  • Create a new row label variable where you set the row labels together in one column and set the indentation
  • If more than 2 row labels, recurse