[Rd] [.data.frame handles drop inconsistently (PR#1530)
ripley@stats.ox.ac.uk
ripley@stats.ox.ac.uk
Wed, 8 May 2002 20:05:24 +0200 (MET DST)
R 1.5.0:
d.df <- data.frame(x = 1:3, y = c("A","D","E"), z = c(6,9,10))
d.df[1,1:3]
xx <- d.df[1,]
xx[, 1:3]
d.df[1,1:3] and xx[, 1:3] should be the same, and they are in S.
d.df[1,1:3] is a data frame.
xx[, 1:3] is a list, and it should not be.
xx[, 1:3, drop=FALSE] is the desired answer.
(This cropped up when looking at merge, which was caught by it.)
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._