Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dput(jj)
- structure(list(month = structure(c(1, 2, 3, 1, 2, 3, 1, 2, 3,
- 1, 2, 3), class = "Date"), student = structure(c(1L, 1L, 1L,
- 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Amy", "Bob"), class = "factor"),
- A = c(9, 7, 6, 8, 6, 9, 3, 2, 1, 5, 6, 5), B = c(6, 7, 8,
- 5, 6, 7, 5, 4, 6, 3, 1, 5)), .Names = c("month", "student",
- "A", "B"), row.names = c(NA, -12L), class = "data.frame")
- IDs<-unique(jj$student)
- uniq <- unique(unlist(jj$month))
- king<-list() #necessary
- for (i in 1:length(IDs)){
- for (j in 1:length(uniq)){
- tmp <- jj[jj$student==IDs[i]& jj$month==uniq[j],]
- tmp1 <- `dimnames<-`(as.matrix(tmp), NULL) #necessary
- #storing column sums as list element
- king[j]<- sum(tmp1$1)
- king[j]<- sum(tmp1$2)
- kong <- `dimnames<-`(do.call(cbind, lapply(king, as.numeric)), NULL) #necessary
- #dividing column sums
- bong<- kong$1/kong$2
- SUMM[i&j,]<- bong #problem here
- }}
- Error: unexpected numeric constant in:
- " #storing column sums as list element
- king[]<- sum(tmp1$1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement