Displaying 1 result from an estimated 1 matches for "outsum".
Did you mean:
outnum
2011 Jan 11
1
how to use "apply" function partial to each vector of a matrix
...y" function to the matrix partially
there is a vector end=c(2,3,1,3)
#sum the 1st 2 numbers of the 1st column
#sum the 1st 3 numbers of the 2nd column
#sum the 1st number of the 3rd column
#sum the 1st 3 numbers of the 4th column
#they are specified by vector end
a for loop
for (i in 1:4)
{
outsum=sum[1:end[i],i]
}
but when I want to do it to a large dataset, it's inefficency becomes a problem, so need vectorization
the "apply" function will sum all of each vector, which is not my purpose
Thank you in advance
Yours sincerely
ZhaoXing
Department of Health Statistics
W...