On Mon, 10 Oct 2005, Marc Schwartz (via MN) wrote:

> On Mon, 2005-10-10 at 10:37 -0400, Afshartous, David wrote:
>>      All,
>>
>>      Is there are a wildcard in R for varible names as in unix?  For example,
>>
>>      rm(results*)
>>
>>      to remove all variable or function names that begin w/ "results"?
>>
>>      cheers,
>>      Dave
>>      ps - please respond directly to [EMAIL PROTECTED]
>
>
> See ?ls, which has a 'pattern' argument, enabling the use of Regex to
> define the objects to be listed and subsequently removed using rm().
>
> You can then use something like:
>
>  rm(list = ls(pattern = "\\bresults."))

One new feature of R-2.2.0 is glob2rx, which converts wildcards to regexps 
for you. E.g.

rm(list = ls(pattern = glob2rc("results*")))

(I think if does it a little better, as that trailing dot is not I think 
correct: result* matches result.)

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to