I recently ran across an unexpected problem caused by combining lists
that contained elements of the same name. I naively thought that the
elements would get overwritten, but rather the "new" element gets added
with the same name. A simplified version is :
> my.list <- list(a = 1)
> new.list <- c(my.list, list(a = "a", b = "b"))
> new.list
$a
[1] 1
$a
[1] "a"
$b
[1] "b"
> new.list$a
[1] 1
I think I understand why this happens, but is there a way to do this
kind of combining and force overwriting if the list already contains an
equivalent name? I can imagine a way using 'lapply', but I'm just
checking to see if there is a way to do it with 'c'. In the cases I'd
be using this, I wouldn't necessarily know beforehand if the new list
contained unique elements or was an "update" list.
Thanks!
Cheers,
e.
--
Eric Archer, Ph.D.
NOAA-SWFSC
8604 La Jolla Shores Dr.
La Jolla, CA 92037
858-546-7121,7003(FAX)
[EMAIL PROTECTED]
"Lighthouses are more helpful than churches."
- Benjamin Franklin
"...but I'll take a GPS over either one."
- Craig George
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.