I have a dataset that has one column for IDs and then 100 columns listing the scores for each of 100 questions, like so:
ID Q1 Q2 ... Q100
S1 1 1 ... 1
I've written my code as follows:
library(reshape2)
new_df <- melt(df, id.vars = "ID", measure.var = c("Q1", "Q100))
However, this obviously doesn't work--it only melts the Q1 and Q100 column. Is there a way to melt Q1 to Q100 either using a string, or using the column locations (i.e., [,2:101]?)
Thanks!