Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wtpmean=aggregate(dat$A20,by=list(dat$sub),mean)
- colnames(wtpmean)=c("sub","mean")
- wtpsd=aggregate(dat$A20,by=list(dat$sub),sd)
- colnames(wtpsd)=c("sub","sd")
- (subset(dat$A20,dat$sub==1)-wtpmean$mean[1])/wtpsd$sd[1]
- ##結果
- >[1] -0.9647826 0.1146944 0.1146944 -0.1551748 0.6544330 -0.8028611 2.0037793
- [8] -0.9647826
- 成功出現sub=1的8次觀察值zscore##
- #想要把這個寫成迴圈,受試者共有117位,每位有8個觀察值
- > zscore=0
- > for(i in 1:936){
- + zscore[i]=(subset(dat$A20,dat$sub==i)-wtpmean$mean[i])/wtpsd$sd[i]}
- ##
- Error in zscore[i] = (subset(dat$A20, dat$sub == i) - wtpmean$mean[i])/wtpsd$sd[i] :
- replacement has length zero
- In addition: There were 50 or more warnings (use warnings() to see the first 50)##
Advertisement
Add Comment
Please, Sign In to add comment