[R] rm(l*)
Gabor Csardi
csardi at rmki.kfki.hu
Mon Jul 14 10:51:50 CEST 2008
Maybe there is a simpler way, but this works fine:
> l1 <- 1
> l2 <-2
> m <-10
> ls()
[1] "l1" "l2" "m"
> rm(list=grep("^l.*", ls(), value=TRUE))
> ls()
[1] "m"
>
You can supply a regular expression to grep.
Gabor
On Mon, Jul 14, 2008 at 10:45:13AM +0200, Oehler, Friderike (AGPP) wrote:
> Dear Rusers,
>
> how can I designate various objects the names of which start (or end) with
> the same letter to remove them all together?
>
> For instance:
> > ls()
> "a","b","c","l1","l2","x"
> > rm(list=ls("l*"))
> > ls()
> "a","b","c",""x"
>
> Is there some parallel to the MySQL query: where col1 like "l%"
>
> Thanks a lot in advance,
> Friderike
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
--
Csardi Gabor <csardi at rmki.kfki.hu> UNIL DGM
More information about the R-help
mailing list