[R] question about lists
harry mamaysky
harry.mamaysky at gmail.com
Thu Apr 19 21:11:24 CEST 2012
I am new to R, and I have been running into the following situation
when I mistype a variable name in some code:
> list1 <- list( a=1, b=2 )
> list2 <- list( a=1 )
> list2$b <- list1$c
> list2
$a
[1] 1
I would think at the point where I am trying to reference a field
called "c" -- that does not exist -- in list1, there would be an error
flagged.
Instead, list1$c returns value NULL, and the assignment "list2$b <-
NULL" does not return any error, but also does not create a field
called "b" in list2.
Is there a way to have R flag the reference to field "c" in list1 as an error?
Thanks,
Harry
More information about the R-help
mailing list