Wacek Kusnierczyk wrote: > is your data a data frame or a matrix? do you want to compute the > differences columnwise, i.e., for each column independently? consider > this example: > > # generate and display dummy data > (d = as.data.frame(replicate(3, sample(5)))) > > # compute successive differences columnwise > as.data.frame(apply(d, 2, diff)) > apply(as.matrix(d), 2, diff) > >
haven't noticed the sum part; you can apply colSums to the above resulting data frame or matrix, e.g.: colSums(apply(d, 2, diff)) vQ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.