[R] Variable Wildcard Value

Dieter Menne dieter.menne at menne-biomed.de
Wed Apr 1 09:35:14 CEST 2009


Francis Smart <fsmart <at> gmail.com> writes:

> 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

If grep on a vector does not help, maybe the following comes closer?
Finding all variables 

rm(list=ls(all=TRUE))
a = 33
aa = 44
dd = 33
c = 3

names = "^a.*"
Vars <- ls()
r <- Vars[grep(names,Vars)]
r # not really correct for names.* and Vars.*

Dieter




More information about the R-help mailing list