On Wed, Feb 2, 2011 at 7:25 PM, Peter Langfelder
wrote:
> On Wed, Feb 2, 2011 at 7:22 PM, Nick Matzke wrote:
>> Oh wait, this basically does it:
>>
>>> if ("a" %in% attributes(z)$names)
>> + print(TRUE)
>> [1] TRUE
>>
>> (but there may be a better way)
>
> If z is a list, you can test
>
> is.null
On Wed, Feb 2, 2011 at 7:22 PM, Nick Matzke wrote:
> Oh wait, this basically does it:
>
>> if ("a" %in% attributes(z)$names)
> + print(TRUE)
> [1] TRUE
>
> (but there may be a better way)
If z is a list, you can test
is.null(z$a)
Peter
__
R-help@r-pr
Oh wait, this basically does it:
> if ("a" %in% attributes(z)$names)
+ print(TRUE)
[1] TRUE
(but there may be a better way)
Cheers!
Nick
On 2/2/11 7:20 PM, Nick Matzke wrote:
I am dealing with an object that sometimes has a certain
attribute, sometimes doesn't. How do I check for this?
"exist
I am dealing with an object that sometimes has a certain
attribute, sometimes doesn't. How do I check for this?
"exists" doesn't work...
===
> z=c()
> z$a = c("c", "d", "f")
> z
$a
[1] "c" "d" "f"
> exists("z")
[1] TRUE
> exists("z$a")
[1] FALSE
===
.
4 matches
Mail list logo