I understand what rowsum()
does, but I'm trying to get it to work for myself. I've used the example provided in R which is structured as such:
x <- matrix(runif(100), ncol = 5)
group <- sample(1:8, 20, TRUE)
xsum <- rowsum(x, group)
What is the matrix of values that is produced by xsum
and how are the values obtained. What I thought was happening was that the values obtained from group
were going to be used to state how many entries from the matrix to use in a rowsum
. For example, say that group = (2,4,3,1,5). What I thought this would mean is that the first two entries going by row would be selected as the first entry to xsum
. It appears as though this is not what is happening.