[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-devel
Subject:    [Rd] `[[<-.data.frame` leaves holes after existing columns and returns a corrupt data frame
From:       Hervé_Pagès <hpages () fredhutch ! org>
Date:       2017-11-21 22:42:33
Message-ID: 5A14ABD9.8070107 () fredhutch ! org
[Download RAW message or body]

Hi,

`[<-.data.frame` is cautious about not leaving holes after existing
columns:

   > `[<-`(data.frame(id=1:6), 3, value=data.frame(V3=11:16))
   Error in `[<-.data.frame`(data.frame(id = 1:6), 3, value = 
data.frame(V3 = 11:16)) :
     new columns would leave holes after existing columns

but `[[<-.data.frame` not so much:

   > `[[<-`(data.frame(id=1:6), 3, value=11:16)
     id      V3
   1  1 NULL 11
   2  2 <NA> 12
   3  3 <NA> 13
   4  4 <NA> 14
   5  5 <NA> 15
   6  6 <NA> 16
   Warning message:
   In format.data.frame(x, digits = digits, na.encode = FALSE) :
     corrupt data frame: columns will be truncated or padded with NAs

The latter should probably behave like the former in that case. Maybe
by sharing more code with it?

Thanks,
H.


-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages@fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic