I am trying to take a filtered database table of text values and create a text report where there are variable number of lines (created by combining several columns for each row in the filtered table) with headings and sub-headings that are created from 2 other columns in the table.
This is to send to an rmarkdown document for creating a word or html doc. I have tried converting to list and using by() with paste to combine columns but cannot get what I want.
df=data.frame(cat1=c("A","A","A","B","B","C","C","C"),
cat2=c("D","D","E","D","F","D","G","G"),
text1=c("text1","text2","text3","text4","text5","text6","text7","text8"),
text2=c("text9","text10","text11","text12","text13","text14","text15","text16"))
I want something like:
A: D:
text1, text9
text2, text10
A: E:
text3, text11
B: D:
text4, text12
B: F:
text5, text13
C: D:
text6, text14
C: G:
text7, text15
text8, text 16
I get complicated lists that I cannot parse.