我有一項調查的數據。它來自一個問題是這樣的:如何合併多個變量以在R中創建新的因子變量?
Did you do any of the following activities during your PhD
Yes, paid by my school. Yes, paid by me. No.
Attended an internationl conference?
Bought textbooks?
的數據自動保存在電子表格中這樣說:
id conf.1 conf.2 conf.3 text.1 text.2 text.3
1 1 1
2 1 1
3 1 1
4 1 1
5
這意味着參與者1出席了她的大學付出了會議;參加者2參加了他所支付的會議,參與者3沒有參加。
我要合併CONF.1,CONF.2和CONF.3和text.1,text.2和text.3單變量
id new.conf new.text
1 1 2
2 2 1
3 3 1
4 3 3
where the number now respresents the categories of the survey question
Thanks for your help
這是一個重塑不合並。嘗試'reshape'(base R),'reshapeasy'(taRifx package)或'reshape2'軟件包。 – 2012-07-22 21:57:28