From hpages at fredhutch.org  Tue Nov 21 23:42:33 2017
From: hpages at fredhutch.org (=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=)
Date: Tue, 21 Nov 2017 14:42:33 -0800
Subject: [Rd] `[[<-.data.frame` leaves holes after existing columns and
 returns a corrupt data frame
Message-ID: <5A14ABD9.8070107@fredhutch.org>

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 at fredhutch.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



[Rd] `[[<-.data.frame` leaves holes after existing columns and returns a corrupt data frame
=?ISO-8859-1?Q?Herv=E9_Pag=E8s?=