我有一些数据,每个参与者对9个对象进行了3次评价(共27次评价)。这9个对象采用了3x3设计(在受试者内),因此有2个因素。
我现在有ID和27个数据列,我需要:
- ID - 2个因素列:表现,情境 - 3个值列:成功,ProbAdmit,Admit
我已经阅读了reshape()、melt()和cast()的手册,但还没有找到实现目标的方法。以下是我的当前进展,您可以从中看到我的实际数据。
以上代码让我得到了这个结果:
我需要的是这样的数据框架。
我现在有ID和27个数据列,我需要:
- ID - 2个因素列:表现,情境 - 3个值列:成功,ProbAdmit,Admit
我已经阅读了reshape()、melt()和cast()的手册,但还没有找到实现目标的方法。以下是我的当前进展,您可以从中看到我的实际数据。
scsc3 <- read.csv("http://swift.cbdr.cmu.edu/data/SCSC3-2006-10-10.csv")
library(reshape)
scsc3.long <- melt(scsc3,id="Participant")
scsc3.long <- cbind(scsc3.long,colsplit(scsc3.long$variable,split="[.]",names=c("Item","Candidate","Performance","Situation")))
scsc3.long$variable <- NULL
scsc3.long$Candidate <- NULL
以上代码让我得到了这个结果:
Participant value Item Performance Situation
4001 5.0 Success GL IL
4001 60 ProbAdmit GL IL
4001 1 Admit GL IL
4002 ....
我需要的是这样的数据框架。
Participant Performance Situation SuccessValue ProbAdmitValue AdmitValue
4001 GL IL 5.0 60 1
...
谢谢!