I am trying to analyse some comments using the tm and snowballC packages in R. I have the output in the following format:
structure(list(Emp.or.man.or.big.idea = c(1, 2, 1, 2, 3), Sentiment = c(0,
-1, 1, 0, -1), x1st = c(0, 0, 1, 0, 0), x2nd = c(0, 0, 1, 0,
0), accept = c(0, 0, 0, 1, 0)), .Names = c("Emp.or.man.or.big.idea",
"Sentiment", "x1st", "x2nd", "accept"), row.names = c(NA, -5L
), class = "data.frame")
My first column is whether the comment is made by manager, employee or it is a big idea. My second column is whether the sentiment is positive, negative or neutral. My 3rd column and onward are specific words and number of mentions for specific employee/manager/big idea and specific sentiment 0/1/-1.
I am trying to understand how to convert the column names to be row names. I am facing two problems when I am trying to use the reshape package but I am not able to pull if off. I have 237 observations and 464 variables so am not sure how to transform the data from column 3 onward so that I can have one unique row for each variable for each unique manager/employee/big idea and each unique sentiment (1/0-1). Same for all other variables from 3 to 464. Simple transpose can't do the trick in this case.
The desired outcome is in this format:
structure(list(Emp.or.man.or.big.idea = c(1, 1, 1, 2, 2, 2, 3,
3, 3), Sentiment = c(0, -1, 1, 0, -1, 1, 0, -1, 1), words = structure(c(2L,
2L, 2L, 3L, 3L, 3L, 1L, 1L, 1L), .Label = c("accept", "x1st",
"x2nd"), class = "factor"), num.mentions = c(2, 1, 3, 4, 2, 3,
2, 5, 4)), .Names = c("Emp.or.man.or.big.idea", "Sentiment", "words",
"num.mentions"), row.names = c(NA, -9L), class = "data.frame")