[R] rbind'ing empty rows in dataframes in 1.4.1 versus 1.5.0
David Kane <David Kane
a296180 at mica.fmr.com
Tue Apr 30 17:08:33 CEST 2002
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list