Dear R-Experts, in my program I have a big workspace. Now I want to look for all variables which have the letters "777" in their name (e.g. ask777first) and afterwards I need to delete those variables. How can I reach this aim? Any ideas, Corinna
one option is use something like the following: a <- 1:10 b777 <- rnorm(10) c777 <- letters[1:6] fit <- lm(b777 ~ a) a777d777 <- 5 ############## lis <- ls() rm(list = c(lis[grep("777", lis)], "lis")) ls() I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Schmitt, Corinna" <Corinna.Schmitt at igb.fraunhofer.de> To: <r-help at stat.math.ethz.ch> Cc: "Schmitt, Corinna" <Corinna.Schmitt at igb.fraunhofer.de> Sent: Thursday, May 03, 2007 9:58 AM Subject: [R] searching for special variables> Dear R-Experts, > > in my program I have a big workspace. Now I want to look for all > variables which have the letters "777" in their name (e.g. > ask777first) > and afterwards I need to delete those variables. How can I reach > this > aim? > > Any ideas, Corinna > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code. >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
ls(pattern=".*777.*") Schmitt, Corinna wrote:> > Dear R-Experts, > > in my program I have a big workspace. Now I want to look for all > variables which have the letters "777" in their name (e.g. ask777first) > and afterwards I need to delete those variables. How can I reach this > aim? >-- View this message in context: http://www.nabble.com/searching-for-special-variables-tf3685103.html#a10300943 Sent from the R help mailing list archive at Nabble.com.
sorry, forgot to delete objects. rm(list=ls(pattern=".*777.*")) Vladimir Eremeev wrote:> > ls(pattern=".*777.*") > > > Schmitt, Corinna wrote: >> >> in my program I have a big workspace. Now I want to look for all >> variables which have the letters "777" in their name (e.g. ask777first) >> and afterwards I need to delete those variables. How can I reach this >> aim? >> > >-- View this message in context: http://www.nabble.com/searching-for-special-variables-tf3685103.html#a10302565 Sent from the R help mailing list archive at Nabble.com.
Try: rm(list = ls(patt = 777)) On 5/3/07, Schmitt, Corinna <Corinna.Schmitt at igb.fraunhofer.de> wrote:> Dear R-Experts, > > in my program I have a big workspace. Now I want to look for all > variables which have the letters "777" in their name (e.g. ask777first) > and afterwards I need to delete those variables. How can I reach this > aim? > > Any ideas, Corinna > > ______________________________________________ > R-help at 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 > and provide commented, minimal, self-contained, reproducible code. >