[R] Variable Wildcard Value

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Wed Apr 1 10:31:47 CEST 2009


Patrick Burns wrote:
> I would be truly amazed if the answer were "yes".
>
> I find this the most fascinating question on R-help
> for a long time, maybe ever.  Can you tell us what
> you have in mind and what your ultimate purpose is?
>

this seems a request for a 'match all' value, somewhat the inverse of NA
(~'match nothing').  i could think of this being useful when you want to
check for duplicates, and want to mark that some entries (e.g., the
unknown ones) are irrelevant for the comparison (i.e., they should match
everything):

    identical(c(1, NA), c(1, 2))
    # FALSE

    identical(c(1, NA), c(1, NA))
    # TRUE
    # confusing!

    # hypothetical
    identical(c(1, *), c(1, 2))
    # TRUE
    identical(c(1, *), c(1, NA))
    # TRUE

not sure about the last one, though, since the original post demanded
that is.na(*) == FALSE

i don't claim this would be useful in practice, just speculating.

vQ

> Patrick Burns
> patrick at burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of "The R Inferno" and "A Guide for the Unwilling S User")
>
> Francis Smart wrote:
>> Is there a wildcard value for vector values in r?
>>
>> For instance:
>>
>>  
>>> M <- *wildcard
>>>     
>>
>>  
>>> (M==1)
>>>     
>> TRUE
>>
>>  
>>> (M=="peanut butter")
>>>     
>> TRUE
>>
>>  
>>> is.na(M)
>>>     
>> FALSE
>>
>> thanks,
>> Francis
>>
>>
>
> ______________________________________________
> R-help at r-project.org 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.




More information about the R-help mailing list