[R] rbind'ing empty rows in dataframes in 1.4.1 versus 1.5.0
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Apr 30 17:44:47 CEST 2002
This is indeed to do with missingness of character strings. Data frames
cannot have missing row names, and that's what your code creates. So give
your missing (it is definitely not `empty') row a valid row name.
On Tue, 30 Apr 2002, David Kane <David Kane wrote:
> Hi,
>
> In 1.4.1, I was able to create extra "empty" rows in a dataframe as so:
>
> > x <- data.frame(a = letters[1:3], b = 1:3)
> > x
> a b
> 1 a 1
> 2 b 2
> 3 c 3
> > x[4,]
> a b
> NA NA NA
> > rbind(x, x[4,])
> a b
> 1 a 1
> 2 b 2
> 3 c 3
> NA NA NA
> > R.version
> _
> platform sparc-sun-solaris2.6
> arch sparc
> os solaris2.6
> system sparc, solaris2.6
> status
> major 1
> minor 4.1
> year 2002
> month 01
> day 30
> language R
>
> This does not work in 1.5.0
>
> > x <- data.frame(a = letters[1:3], b = 1:3)
> > x
> a b
> 1 a 1
> 2 b 2
> 3 c 3
> > x[4,]
> a b
> <NA> <NA> NA
> > rbind(x, x[4,])
> Error in if (nrow > 0 && all(ri == 1:ni)) seq(from = nrow + 1, length = ni) else ri :
> missing value where logical needed
> > R.version
> _
> platform sparc-sun-solaris2.6
> arch sparc
> os solaris2.6
> system sparc, solaris2.6
> status
> major 1
> minor 5.0
> year 2002
> month 04
> day 29
> language R
>
> Note that, contrary to my first guess, this has nothing (?) to do with the new
> NA in character vectors since I see the same behavior with numeric only
> dataframes.
>
> > x <- data.frame(a = 5:7, b = 1:3)
> > x
> a b
> 1 5 1
> 2 6 2
> 3 7 3
> > x[4,]
> a b
> <NA> NA NA
> > rbind(x, x[4,])
> Error in if (nrow > 0 && all(ri == 1:ni)) seq(from = nrow + 1, length = ni) else ri :
> missing value where logical needed
>
>
> I didn't see anything in the NEWS about this change. Could someone please
> explain what is going one? Any words of wisom about the "right" way to create
> empty rows in dataframe (which I then fill in variable by variable later in the
> program) would also be appreciated.
>
> Thanks,
>
> Dave Kane
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help 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-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
Brian D. Ripley, ripley at 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-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list