Re: [R] Exclusion of elements in a vector

2008-09-25 Thread Gabor Grothendieck
Try this: vector[ setdiff(seq_along(vector), as.numeric(idx)) ] where idx is your vector of indices to exclude, e.g. idx <- 3:4 idx <- numeric(0) idx <- NULL The last one gets converted to numeric(0) by as.numeric so it still works. On Thu, Sep 25, 2008 at 7:43 AM, Stefan Fritsch <[EMAIL PROTEC

Re: [R] Exclusion of elements in a vector

2008-09-25 Thread Douglas Bates
On Thu, Sep 25, 2008 at 8:15 AM, Chuck Cleland <[EMAIL PROTECTED]> wrote: > On 9/25/2008 7:43 AM, Stefan Fritsch wrote: >> Dear R Users, >> >> I want to exclude elements in a vector by: >> >> vector[-exclude] >> >> is it intended to cause an error if no elements are excluded? >> >>> vector <- 1:10

Re: [R] Exclusion of elements in a vector

2008-09-25 Thread Chuck Cleland
On 9/25/2008 7:43 AM, Stefan Fritsch wrote: > Dear R Users, > > I want to exclude elements in a vector by: > > vector[-exclude] > > is it intended to cause an error if no elements are excluded? > >> vector <- 1:10 >> exclude <- NULL >> vector[-exclude] > Error in -exclude > > or am I just def

[R] Exclusion of elements in a vector

2008-09-25 Thread Stefan Fritsch
Dear R Users, I want to exclude elements in a vector by: vector[-exclude] is it intended to cause an error if no elements are excluded? > vector <- 1:10 > exclude <- NULL > vector[-exclude] Error in -exclude or am I just definig exclude wrong, if no elements should be excluded? with kind reg