Dear Steve,
Using Jim Holtman's x data, you can also try the following for columns 3 and
4:
a <- with(x, apply(x[,3:4], 2, tapply, site,function(x) cumsum(x)))
x[,c('cvar1','cvar2')] <- do.call(cbind,lapply(a, function(x) do.call(c,x)))
x
HTH,
Jorge
On Wed, Jun 17, 2009 at 11:48 AM, SEUNG CHEO
Here is one way of doing it:
> x <- read.table(textConnection("sitedistancevar1var2
+ 1 10 1 0
+ 1 20 0 1
+ 1 30 1 2
+ 1 40 3 3
+ 1 50 1 4
+ 2 10
Dear R-Help List,
I have a question about data manipulation. I tried to make code myself but too
much for me. I would greatly appreciate your help.
I have data set consisting of site (from 1 to N1) and distance and there are
several variables (1 to N2) collected from each sampling site. I am in
3 matches
Mail list logo