An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111020/aa238099/attachment.pl>
How to remove all objects except the sequence
3 messages · Sergio René Araujo Enciso, Eik Vettorazzi, Araujo.Enciso at gmail.com
Hi Sergio, how about this: rm(list=setdiff(ls(),"z")) cheers. Am 20.10.2011 11:00, schrieb Sergio Ren? Araujo Enciso:
Dear All:
I would like to know if there is plausible way to say to R to remove all
elements in the memory but the sequence. I have a code which makes a loop,
and what I want is after the programme has performed all the operation over
every "i"th element, to remove all the objects, expect the sequence
parameter. I included the option "rm(list=ls(all=TRUE))", but obviously that
removes the sequence as well. I know that I can give the names of the
objects to remove, but instead of doing so I would like to tell R remove all
but the sequence. Is there a way for doing so? The reason for removing all
the objects after each operation is saving some memory, as the operation I
am doing involves some bootstrapping, after the loop reaches a certain "i"th
element, the operations start to be really slow. So I want to faster the
loop by removing the objects and free memory after every operation.
Below is my code:
setwd("C:\\Dokumente und Einstellung\\.....")
library("tsDyn")
z<-(1:1000)### sequence parameter
sink("prueba.txt")
for (i in seq(z))
{
P1<-read.csv("2R_EQ_P_R1.csv")
P2<-read.csv("2R_EQ_P_R2.csv")
c<-data.frame(P1[i],P2[i])
c.t<-ts(c)*-1
try(print(z[i]))
try(SeoTest<-TVECM.SeoTest(c.t, lag=1, beta=1, trim=0.1, nboot=100))
try(summary(SeoTest))
rm(list=ls(all=TRUE)) ### Here I want to erase all but "z"
}
best,
Sergio Ren?
[[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.
Eik Vettorazzi Department of Medical Biometry and Epidemiology University Medical Center Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790 -- Pflichtangaben gem?? Gesetz ?ber elektronische Handelsregister und Genossenschaftsregister sowie das Unternehmensregister (EHUG): Universit?tsklinikum Hamburg-Eppendorf; K?rperschaft des ?ffentlichen Rechts; Gerichtsstand: Hamburg Vorstandsmitglieder: Prof. Dr. Guido Sauter (Vertreter des Vorsitzenden), Dr. Alexander Kirstein, Joachim Pr?l?, Prof. Dr. Dr. Uwe Koch-Gromus
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111020/3aaf1f5f/attachment.pl>