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

Patrick Burns pburns at pburns.seanet.com
Wed Oct 30 17:12:30 CET 2013


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 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.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Patrick Burns
pburns at pburns.seanet.com
twitter: @burnsstat @portfolioprobe
http://www.portfolioprobe.com/blog
http://www.burns-stat.com
(home of:
  'Impatient R'
  'The R Inferno'
  'Tao Te Programming')



More information about the R-help mailing list