【发布时间】:2012-07-22 21:50:13
【问题描述】:
我有来自一项调查的数据。它来自一个看起来像这样的问题:
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(基础R)、reshapeasy(taRifx 包)或reshape2包。