Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. dput(jj)
  2. structure(list(month = structure(c(1, 2, 3, 1, 2, 3, 1, 2, 3,
  3. 1, 2, 3), class = "Date"), student = structure(c(1L, 1L, 1L,
  4. 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Amy", "Bob"), class = "factor"),
  5. A = c(9, 7, 6, 8, 6, 9, 3, 2, 1, 5, 6, 5), B = c(6, 7, 8,
  6. 5, 6, 7, 5, 4, 6, 3, 1, 5)), .Names = c("month", "student",
  7. "A", "B"), row.names = c(NA, -12L), class = "data.frame")
  8.  
  9. IDs<-unique(jj$student)
  10. uniq <- unique(unlist(jj$month))
  11. king<-list() #necessary
  12. for (i in 1:length(IDs)){
  13. for (j in 1:length(uniq)){
  14. tmp <- jj[jj$student==IDs[i]& jj$month==uniq[j],]
  15. tmp1 <- `dimnames<-`(as.matrix(tmp), NULL) #necessary
  16. #storing column sums as list element
  17. king[j]<- sum(tmp1$1)
  18. king[j]<- sum(tmp1$2)
  19. kong <- `dimnames<-`(do.call(cbind, lapply(king, as.numeric)), NULL) #necessary
  20. #dividing column sums
  21. bong<- kong$1/kong$2
  22. SUMM[i&j,]<- bong #problem here
  23. }}
  24.  
  25. Error: unexpected numeric constant in:
  26.  
  27. " #storing column sums as list element
  28. king[]<- sum(tmp1$1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement