RE: [R] Vector indices and minus sign

2003-11-14 Thread Liaw, Andy
al Message- From: Patrick Burns [mailto:[EMAIL PROTECTED] Sent: Friday, November 14, 2003 12:06 PM To: Liaw, Andy Cc: 'Thomas Lumley'; David Orme; [EMAIL PROTECTED] Subject: Re: [R] Vector indices and minus sign Liaw, Andy wrote: From: Thomas Lumley [mailto:[EMAIL PROTECTED] <

Re: [R] Vector indices and minus sign

2003-11-14 Thread Tony Plate
At Friday 05:06 PM 11/14/2003 +, Patrick Burns wrote: Liaw, Andy wrote: > [material omitted...] > >I guess this can only work if "-" is treated specially in the subset >operators, so that, e.g., x[-"Andy"] would also work. (This would be nice, >IMHO.) > I agree that x[-c("Andy", "Pat")] wou

Re: [R] Vector indices and minus sign

2003-11-14 Thread Patrick Burns
Liaw, Andy wrote: >>From: Thomas Lumley [mailto:[EMAIL PROTECTED] >> >>On Fri, 14 Nov 2003, David Orme wrote: >> >> >> >>>Hi, >>> >>>I got caught out by this behaviour in 1.8.0 and I wondered why this >>>happens: >>> >>> >>> >>Some anomaly of this sort is unavoidable because R allows

RE: [R] Vector indices and minus sign

2003-11-14 Thread Liaw, Andy
> From: Thomas Lumley [mailto:[EMAIL PROTECTED] > > On Fri, 14 Nov 2003, David Orme wrote: > > > Hi, > > > > I got caught out by this behaviour in 1.8.0 and I wondered why this > > happens: > > > > Some anomaly of this sort is unavoidable because R allows > positive or negative numeric indices

Re: [R] Vector indices and minus sign

2003-11-14 Thread Thomas Lumley
On Fri, 14 Nov 2003, David Orme wrote: > Hi, > > I got caught out by this behaviour in 1.8.0 and I wondered why this > happens: > Some anomaly of this sort is unavoidable because R allows positive or negative numeric indices. It can't distinguish between a vector of no positive numbers and a vect

Re: [R] Vector indices and minus sign

2003-11-14 Thread Patrick Burns
S Poetry, page 72. If there is nothing there, then R can't know that you want the nothing to be negative. Patrick Burns Burns Statistics [EMAIL PROTECTED] +44 (0)20 8525 0696 http://www.burns-stat.com (home of S Poetry and "A Guide for the Unwilling S User") David Orme wrote: Hi, I got caught o

RE: [R] Vector indices and minus sign

2003-11-14 Thread Gabor Grothendieck
ot;b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" [20] "t" "u" "v" "w

Re: [R] Vector indices and minus sign

2003-11-14 Thread Thomas W Blackwell
David - I had to try your example verbatim before I understood what is happening. index <- numeric() creates a vector with no entries. Therefore the subscript is neither positive or negative, rather it contains no numeric values, so the return contains no entries either. Works the same in R-1.7

Re: [R] Vector indices and minus sign

2003-11-14 Thread Peter Dalgaard
David Orme <[EMAIL PROTECTED]> writes: > Hi, > > I got caught out by this behaviour in 1.8.0 and I wondered why this > happens: > > I have a list of vectors and was using lapply and grep to remove > matched elements that occur in only a subset of the elements of the > list: > locs <- lappl

[R] Vector indices and minus sign

2003-11-14 Thread David Orme
Hi, I got caught out by this behaviour in 1.8.0 and I wondered why this happens: I have a list of vectors and was using lapply and grep to remove matched elements that occur in only a subset of the elements of the list: locs <- lapply(locs, function(x){x[- grep("^x", x)]}) The problem is tha