I want to stack a frame but I think I do not use the right way...
myframe
sex = F
q8
cars N U Y
1 35 31 10
2 34 23 7
3 132 109 35
4 38 36 14
5 7 5 2
, , sex = M
q8
cars N U Y
1 49 22 16
2 24 13 8
3 136 52 33
4 37 31 32
5 15 10 4
f = c(myframe[1:15])
m = c(myframe[16:30])
S <- stack(data.frame(f,m))
names(S)=c("num","gender")
group=c("1","1","1","2","2","2","3","3","3","4","4","4","5","5","5","6","6","6","1","1","1","2","2","2","3","3","3","4","4","4","5","5","5")
num=S$num
gender=S$gender
twoway.df=data.frame(num,group,gender)
twoway.df
1 1 35 f
2 1 31 f
3 1 10 f
4 2 24 f
5 2 13 f
....
could you help me do it better ?
dput(myframe)to provide reproducible data set. - Marek