Hi,

Since you insist, here is something that I think matches the specifications :

wildcard <- function( ) structure( NULL, class = "wildcard" )
Ops.wildcard <- function (e1, e2){
   if (nargs() == 1L)
       return( e1 )
   result <- switch(.Generic,
       `<` = , `>` = , `==` = ,
       `<=` = , `>=` = TRUE, `!=` = FALSE)
   result
}
is.na.wildcard <- function( x ) FALSE


> w == 1
[1] TRUE
> w == "peanut butter"
[1] TRUE
> is.na( w )
[1] FALSE
> "peanut butter" == w
[1] TRUE
> w == w
[1] TRUE
> w != w
[1] FALSE

# Is negation of a wildcard also a wildcard, or should it be a bizarro wildcard ?
> (!w) == 2
[1] TRUE


Not really sure how this could be useful though, and would also be interested in Francis end game.

Romain


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?

Patrick Burns
patr...@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@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.





--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

______________________________________________
R-help@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.

Reply via email to