Ulrich Leopold
2002-Jul-25 11:58 UTC
[R] remove objects(1-20, 25-30) OR remove objects(...) except(...)??
Dear list, I would like to do a remove like either remove objects(1-20, 25-30) OR remove objects(...) except(...) I only found the approach rm(pat=) which is not suitable as there would be too many patterns. Can I also remove objects by their given number in ls() or do a remove but exclude certain objetcs? Regards, Ulrich -- __________________________________________________ Ulrich Leopold MSc. Department of Physical Geography Institute for Biodiversity and Ecosystem Dynamics Faculty of Science University of Amsterdam Nieuwe Achtergracht 166 NL-1018WV Amsterdam Phone: +31-(0)20-525-7456 (7451 Secretary) Fax: +31-(0)20-525-7431 Email: uleopold at science.uva.nl http://www.frw.uva.nl/soil/Welcome.html Check us also out at: Netherlands Centre for Geo-ecological Research http://www.frw.uva.nl/icg -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk
2002-Jul-25 12:43 UTC
[R] remove objects(1-20, 25-30) OR remove objects(...) except(...)??
On Thu, 25 Jul 2002, Ulrich Leopold wrote:> Dear list, > > I would like to do a remove like either > > remove objects(1-20, 25-30) OR remove objects(...) except(...)rm(list=ls()[c(1:20, 25:30)])> I only found the approach rm(pat=) which is not suitable as there would be > too many patterns. > > Can I also remove objects by their given number in ls() or do a remove but > exclude certain objetcs?Just use standard S indexing. -- Brian D. Ripley, ripley at stats.ox.ac.uk 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Joerg Maeder
2002-Jul-25 13:33 UTC
[R] remove objects(1-20, 25-30) OR remove objects(...) except(...)??
Hello Ulrich, i use the following function to remove all objects with names with one or two letters. I use such variable names for temporary objects. I think you can use something similary for your problem clear <- function(){ ll<-objects(1) ll<-ll[nchar(ll)<3] remove(list=ll,pos=1) } gruess joerg Ulrich Leopold wrote:> > Dear list, > > I would like to do a remove like either > > remove objects(1-20, 25-30) OR remove objects(...) except(...) > > I only found the approach rm(pat=) which is not suitable as there would be > too many patterns. > > Can I also remove objects by their given number in ls() or do a remove but > exclude certain objetcs? > > Regards, Ulrich > > -- > __________________________________________________ > > Ulrich Leopold MSc. > > Department of Physical Geography > Institute for Biodiversity and Ecosystem Dynamics > Faculty of Science > University of Amsterdam > Nieuwe Achtergracht 166 > NL-1018WV Amsterdam > > Phone: +31-(0)20-525-7456 (7451 Secretary) > Fax: +31-(0)20-525-7431 > Email: uleopold at science.uva.nl > http://www.frw.uva.nl/soil/Welcome.html > > Check us also out at: > Netherlands Centre for Geo-ecological Research > http://www.frw.uva.nl/icg > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Joerg Maeder .:|:||:..:.||.:: maeder at atmos.umnw.ethz.ch Tel: +41 1 633 36 25 .:|:||:..:.||.:: http://www.iac.ethz.ch/staff/maeder PhD student at INSTITUTE FOR ATMOSPHERIC AND CLIMATE SCIENCE (IACETH) ETH Z?RICH Switzerland -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Agustin Lobo
2002-Jul-25 14:05 UTC
[R] remove objects(1-20, 25-30) OR remove objects(...) except(...)??
I would make a vector with the list of files to removed. If the position is the only way you have to select, you could use: toberemoved <- ls() toberemoved <- toberemoved[c(1:20,25:30)] check that toberemoved is what you want to remove and then remove(list=toberemoved) Agus Dr. Agustin Lobo Instituto de Ciencias de la Tierra (CSIC) Lluis Sole Sabaris s/n 08028 Barcelona SPAIN tel 34 93409 5410 fax 34 93411 0012 alobo at ija.csic.es On Thu, 25 Jul 2002, Ulrich Leopold wrote:> Dear list, > > I would like to do a remove like either > > remove objects(1-20, 25-30) OR remove objects(...) except(...) > > I only found the approach rm(pat=) which is not suitable as there would be > too many patterns. > > Can I also remove objects by their given number in ls() or do a remove but > exclude certain objetcs? > > Regards, Ulrich > > -- > __________________________________________________ > > Ulrich Leopold MSc. > > Department of Physical Geography > Institute for Biodiversity and Ecosystem Dynamics > Faculty of Science > University of Amsterdam > Nieuwe Achtergracht 166 > NL-1018WV Amsterdam > > Phone: +31-(0)20-525-7456 (7451 Secretary) > Fax: +31-(0)20-525-7431 > Email: uleopold at science.uva.nl > http://www.frw.uva.nl/soil/Welcome.html > > Check us also out at: > Netherlands Centre for Geo-ecological Research > http://www.frw.uva.nl/icg > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
John Fox
2002-Jul-25 14:21 UTC
[R] remove objects(1-20, 25-30) OR remove objects(...) except(...)??
Dear Ulrich, rm(list=ls()[c(1:20, 25:30)] should do what you want (If I understand the question correctly). John At 01:58 PM 7/25/2002 +0200, you wrote:>Dear list, > >I would like to do a remove like either > >remove objects(1-20, 25-30) OR remove objects(...) except(...) > >I only found the approach rm(pat=) which is not suitable as there would be >too many patterns. > >Can I also remove objects by their given number in ls() or do a remove but >exclude certain objetcs? > >Regards, Ulrich----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox ----------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Tony Plate
2002-Jul-25 15:36 UTC
[R] remove objects(1-20, 25-30) OR remove objects(...) except(...)??
You can remove everything but specified objects using setdiff() > a <- 1 > b <- 2 > c <- 3 > objects() [1] "a" "b" "c" > rm(list=setdiff(objects(), "a")) > objects() [1] "a" > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._