[R] how to not match partial names
Thomas Lumley
tlumley at uw.edu
Sun May 8 01:18:36 CEST 2011
On Sun, May 8, 2011 at 11:09 AM, William Revelle <lists at revelle.net> wrote:
> Dear friends,
>
> How do I stop partial matching of list names?
>
> e.g.,
>
> x <- list(AAAA="aaaaa", BBBBB="bbbbb")
> is.null(x$A) #returns FALSE even though there is no element A.
>
> if(is.null(x$A)) {result <- x$BBBB} else {result <- x$A}
> result #is aaaa even though there is no x$A element
>
x[["A"]]
-thomas
--
Thomas Lumley
Professor of Biostatistics
University of Auckland
More information about the R-help
mailing list