Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread William Dunlap
x27;subset' must evaluate to logical Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf > Of David Winsemius > Sent: Wednesday, October 30, 2013 10:28 AM > To: Ja

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread Carl Witthoft
Both PBurns and DWin are correct. I just thought I'd add a clunky "safety check" approach I use now and then: Before doing the actual subset, i.e. df[-which(something),] , do something like if (length(which(something)) <1 ) {skip the subsetting} else df[-which(something)] -- View this

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread David Winsemius
On Oct 30, 2013, at 6:04 AM, Jack Tanner wrote: > I'm not sure if this is correct behavior or not, but it seems > counterintuitive > to me: > > dat <- data.frame(id=1:5, let=letters[1:5]) > # A. omits the first row > dat[- 1, ] > > # B. unexpectedly omits ALL rows > dat[- integer(0), ] > > I

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread Patrick Burns
This is Circle 8.1.13 of 'The R Inferno'. http://www.burns-stat.com/documents/books/the-r-inferno/ Pat On 30/10/2013 13:04, Jack Tanner wrote: I'm not sure if this is correct behavior or not, but it seems counterintuitive to me: dat <- data.frame(id=1:5, let=letters[1:5]) # A. omits the firs

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread S Ellison
> > dat[- integer(0), ] > > unexpectedly omits ALL rows > > > > It would be less surprising if there were no rows omitted in the (B) case. I tried this on two experienced R users here and their first thought* was, interestingly, as Jack indicated; that -integer(0) should drop nothing. But

Re: [R] omitting integer(0) rows from data frame

2013-10-30 Thread Gerrit Eichner
Hi, Jack, well, I disagree: What do you expect to grab out of a bucket (= data frame) if you do not at all grab into it (indexing with an _empty_ index, i.e. with nothing)? And changing the sign of nothing is still nothing ... Hth -- Gerrit On Wed, 30 Oct 2013, Jack Tanner wrote: I'm not

[R] omitting integer(0) rows from data frame

2013-10-30 Thread Jack Tanner
I'm not sure if this is correct behavior or not, but it seems counterintuitive to me: dat <- data.frame(id=1:5, let=letters[1:5]) # A. omits the first row dat[- 1, ] # B. unexpectedly omits ALL rows dat[- integer(0), ] It would be less surprising if there were no rows omitted in the (B) case.