[R] assigning to data frames with whole columns of NAs

David Firth david.firth at nuffield.oxford.ac.uk
Sat Nov 25 11:58:43 CET 2000


I suppose this could be described as a feature (it seems to be similar in S-Plus), but it looks to me more like a bug.  Why can't the assignment below to a row of "emptyframe" (or "anotherframe") be made?  This with R --vanilla (version info below).

Regards -- David
David Firth                        Phone +44 1865 278544
Nuffield College                   Fax   +44 1865 278621
Oxford OX1 1NF                     Secretary +44 1865 278612
United Kingdom                     Email david.firth at nuffield.oxford.ac.uk


> emptyframe<-data.frame(a=c(NA,NA),b=c(NA,NA))
> emptyframe
   a  b
1 NA NA
2 NA NA
> emptyframe[1,]<-c(1,2)
Warning messages: 
1: invalid factor level, NAs generated in: [<-.factor(*tmp*, iseq, value = vjj) 
2: invalid factor level, NAs generated in: [<-.factor(*tmp*, iseq, value = vjj) 
> emptyframe
   a  b
1 NA NA
2 NA NA
> anotherframe<-data.frame(a=c(8,9),b=c(NA,NA))
> anotherframe
  a  b
1 8 NA
2 9 NA
> anotherframe[1,]<-c(1,2)
Warning message: 
invalid factor level, NAs generated in: [<-.factor(*tmp*, iseq, value = vjj) 
> anotherframe
  a  b
1 1 NA
2 9 NA
> yetanotherframe<-data.frame(a=c(8,NA),b=c(9,NA))
> yetanotherframe
   a  b
1  8  9
2 NA NA
> yetanotherframe[1,]<-c(1,2)   #  no problem with this one
> yetanotherframe
   a  b
1  1  2
2 NA NA

> version
         _                
platform i686-pc-linux-gnu
arch     i686             
os       linux-gnu        
system   i686, linux-gnu  
status                    
major    1                
minor    1.1              
year     2000             
month    August           
day      15               
language R 
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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