[R] dataframes without data
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Nov 19 12:43:30 CET 1999
"Wolfgang Koller" <koller2 at fgr.wu-wien.ac.at> writes:
> Hi!
>
> Yesterday I posted the following problem:
>
> > There seems to be some inconsistency in the following behaviour:
> >
> > > MYDATA <- data.frame(b=c("A","B","C"),x=c(1,2,3))
> > > MYDATA
> > b x
> > 1 A 1
> > 2 B 2
> > 3 C 3
> > > MYDATAnew <- MYDATA[0:0,]
> > > MYDATAnew
> > [1] b x
> > <0 rows> (or 0-length row.names)
> > > MYDATAnew <- rbind(MYDATA[0:0,],MYDATA)
> > > MYDATAnew
> > b x
> > 1 1 1
> > 2 2 2
> > 3 3 3
> >
> > Does R forget the type of the columns of a data.frame when the
> > data.frame contains no data??
This seems to be fixed in the upcoming version, but the example scared
up a bug in the new code (thanks!).
> MYDATAnew <- rbind(MYDATA[0:0,],MYDATA)
> MYDATAnew
b x
1 A 1
2 B 2
3 C 3
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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