Guest User

Untitled

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