Re: [R] Clever R syntax for extracting a subset of observations

2004-04-11 Thread Gabor Grothendieck
sdratio <- function(D, d) with( D[d,], sd(x)/sd(y) ) Ajay Shah mayin.org> writes: : : I know that if: :x = seq(1,10) :d = c(7,3,2) : and if I say :y = x[d] : then I get the vector y as (7,3,2). Very clever! This idea is used : intensively with the boot library. : : Now consider

Re: [R] Clever R syntax for extracting a subset of observations

2004-04-11 Thread Ko-Kang Kevin Wang
Hi, - Original Message - From: "Ajay Shah" <[EMAIL PROTECTED]> > > But this doesn't work since if D is a data frame, you can't say > D[d]. Let me show you: > > > x = runif(100) > > y = runif(100) > > D = data.frame(x, y) > > d = c(7,3,2) > > E = D[d] > Error in "[.data.frame"(D, d) : undef

[R] Clever R syntax for extracting a subset of observations

2004-04-11 Thread Ajay Shah
I know that if: x = seq(1,10) d = c(7,3,2) and if I say y = x[d] then I get the vector y as (7,3,2). Very clever! This idea is used intensively with the boot library. Now consider the following code (which works):