I have a data frame which extracts a message thread posted on a discussion forum. By joining tables from a database, I get a structure which looks like this:
threadStarterName1 threadstarter1 comment1 commenterName1
threadStarterName1 threadstarter1 comment2 commenterName2
threadStarterName1 threadstarter1 comment3 commenterName3
threadStarterName1 threadstarter1 comment4 commenterName4
threadStarterName1 threadstarter1 comment5 commenterName5
Code to create this dataframe:
df=data.frame("threadStarterName"=c("threadStarterName1","threadStarterName1","threadStarterName1","threadStarterName1","threadStarterName1"),
"threadStarter"=c("threadStarter1","threadStarter1","threadStarter1","threadStarter1","threadStarter1"),
"comment"=c("comment1","comment2","comment3","comment4","comment5"),
"commenterName"=c("commenterName1","commenterName2","commenterName3","commenterName4","commenterName5"))
I want to reformat this data frame to extract values as follows, which I can then print out in R-markdown for a report:
threadstarter1 threadStarterName1
comment1 commenterName1
comment2 commenterName2
comment3 commenterName3
comment4 commenterName4
comment5 commenterName5
Thanks in advance!