我有一项调查的数据。它来自一个问题是这样的:如何合并多个变量以在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