[Rd] `[[<-.data.frame` leaves holes after existing columns and returns a corrupt data frame
Hervé Pagès
hpages at fredhutch.org
Tue Nov 21 23:42:33 CET 2017
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
More information about the R-devel
mailing list