I am working on survey data with 512 variables. The amount of variables is high because each respondent answers the same question for multiple brands. So each variable, for example 'preference' has 20 columns, for each brand a respondent could possible know. I want one additional column, which is brand, and I did not manage this yet.
I applied the tidyr package and this works very well for the first set of variables:
TestSet100<-as.data.frame(TestSet100)
TestSet100$ID <- factor(TestSet100$ID)
Test_long<-reshape(TestSet100long, varying=c(unaided_b1:unaided_b20), direction="long", idvar= "ID", sep="_")
The result is exactly what I need. But, it goes wrong as soon as I start with the next one:
TestSet100long3<-gather(TestSet100long, brand, aided_awareness, aided_b1:aided_b20, factor_key=T)
Because then it adds: brand unaided_awareness, brand aided_awareness, in stead of one column with the variable brand, and two with unaided_awareness and aided_awareness.
But with the third one, it goes totally wrong, because then the result is an error.
TestSet100long4<-gather(TestSet100long3, brand, familiarity, fami_b1:fami_b20, factor_key=T)
Error: is_dictionaryish(x) is not TRUE