Your code for iy doesn't work as providedI'll assume you meant this instead:
iy <- list(c(1, 2),c(1, 2), c(1, 2, 3, 4), c(2, 3, 5), c(4), c(5, 6,
7), c(7, 8, 9))
Then
sapply(iy, function(x) sum(Y1[x]))
Michael
On Sat, Mar 10, 2012 at 5:01 PM, aldi wrote:
> Hi,
>
> I have a vector
> Y1 <-c
Hi,
I have a vector
Y1 <-c(8, 11, 7, 5, 6, 3, 6, 3, 3)
and an index
iy <-c(c(1, 2),c(1 2), c(1, 2, 3, 4), c(2, 3, 5), c(4), c(5, 6, 7), c(7,
8, 9))
how can I produce the mean, or the sum of the elements specified in the
index iy from the vector Y1?
expecting something like this for th
2 matches
Mail list logo