[R] How to test if t[["cat"]] exists ?

Charilaos Skiadas cskiadas at gmail.com
Wed Apr 16 04:44:00 CEST 2008


On Apr 15, 2008, at 9:53 PM, Ng Stanley wrote:

> Hi,
>
>> t <- list("cat"=1)
>> exists("t")
> [1] TRUE
>> exists("t[["cat"]]")
> Error: unexpected symbol in "exists("t[["cat"
>> exists("t[[\"cat\"]]")
> [1] FALSE

Perhaps what you want is:

"cat" %in% names(t)

> Thanks
> Stanley

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College



More information about the R-help mailing list