Kevin.Wright@pioneer.com
2002-Jun-27 16:13 UTC
data.frame does not recycle consistently (PR#1713)
Full_Name: Kevin Wright Version: 1.5.1 OS: Windows 95 Submission from: (NULL) (170.54.59.160) Note that the examples below do work in S (S-Plus 2000). It appears that data.frame does not recycle text strings. Maybe has something to do with coercion to factors???> data.frame(x=1:2,y=1)x y 1 1 1 2 2 1> data.frame(x=c("A","B"),y=T)x y 1 A TRUE 2 B TRUE> data.frame(x=c("A","B"),y="C")Error in data.frame(x = c("A", "B"), y = "C") : arguments imply differing number of rows: 2, 1 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk
2002-Jun-27 16:52 UTC
data.frame does not recycle consistently (PR#1713)
On Thu, 27 Jun 2002 Kevin.Wright@pioneer.com wrote:> Full_Name: Kevin Wright > Version: 1.5.1 > OS: Windows 95 > Submission from: (NULL) (170.54.59.160) > > > > Note that the examples below do work in S (S-Plus 2000). > > It appears that data.frame does not recycle text strings. Maybe has something > to do with coercion to factors???Yes, it is. Not sure why that makes it inconsistent, though. Vectors are recycled, other objects are not, and that is determined after conversion to a column of a data frame. We could fairly easily allow factors and simple "AsIs" objects to be recycled. BTW, S-PLUS 2000 is not S, and its data frame code is quite a lot different from the original S code. It also makes mistakes: compare> data.frame(x=c("A","B"),y=I("C")) > data.frame(x=c("A","B"),y=I(rep("C", 2)))> > > data.frame(x=1:2,y=1) > x y > 1 1 1 > 2 2 1 > > > data.frame(x=c("A","B"),y=T) > x y > 1 A TRUE > 2 B TRUE > > > data.frame(x=c("A","B"),y="C") > Error in data.frame(x = c("A", "B"), y = "C") : > arguments imply differing number of rows: 2, 1 > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._