OK;首先,我們創建一個大的數據幀爲所有參與者:
result<-rbind(dfrforparticipant1, dfrforparticipant2,...dfrforparticipant6) #you'll have to fill out the proper names of the original data.frames
接下來,我們添加一列的參與者ID:
numTrials<-50 #although 100 is also mentioned in your question
result$P<-as.factor(rep(1:6, each=numTrials))
最後,我們需要從「寬」格式去「長」格式(我假設你的列名稱保存每個條件的結果稱爲C1,C2等;我也假設你的原始data.frames已經擁有一個名爲T的列來表示這個試驗),像這樣(未經測試,因爲您沒有提供示例數據):
orgcolnames<-paste("C", 1:10, sep="")
result2<-reshape(result, varying=list(orgcolnames), v.names="val", idvar=c("T","P"), timevar="C", times=seq_along(orgcolnames), direction="long")
你想要的是現在在result2
。
這純粹是一個代碼問題,而不是一個統計問題。它應該被遷移到SO R. – John
你可能想要檢查stack()函數,它可以幫助你... – thias