Re: [R] Removing a list of Objects

From: Gabor Csardi <csardi_at_rmki.kfki.hu>
Date: Wed, 09 May 2007 11:31:29 +0200

I assumed that 'a' is a character vector. In your case it seams that 'a' is a list with a single element, a character vector. I've no idea why you would want to use such a data structure for this, but if you do want to, then the command is

rm(a[[1]])

See also ?rm and maybe also 'Introduction to R' could be useful.

Gabor

On Wed, May 09, 2007 at 02:33:16PM +0530, Patnaik, Tirthankar wrote:
> Hi Gabor,
> Tried this, and didn't quite work.
>
> > a <- list(paste("C243.Daily",sep="",1:5))
> > a
> [[1]]
> [1] "C243.Daily1" "C243.Daily2" "C243.Daily3" "C243.Daily4"
> "C243.Daily5"
>
> > rm(list=a)
> Error in remove(list, envir, inherits) : invalid first argument
> >
>
> -Tir
>
> -----Original Message-----
> From: Gabor Csardi [mailto:csardi_at_rmki.kfki.hu]
> Sent: Wednesday, May 09, 2007 12:37 PM
> To: Patnaik, Tirthankar [GWM-CIR]
> Cc: r-help_at_stat.math.ethz.ch
> Subject: Re: [R] Removing a list of Objects
>
> Hmmm,
>
> rm(list=a)
>
> is what you want.
>
> Gabor
>
> On Wed, May 09, 2007 at 10:29:05AM +0530, Patnaik, Tirthankar wrote:
> > Hi,
> > I have a simple beginner's question on removing a list of
> objects.
> > Say I have objects C243.Daily1, C243.Daily2...C243.Daily5 in my
> > workspace. I'd like to remove these without using rm five times.
> >
> > So I write.
> >
> > > a <- list(paste("C243.Daily",sep="",1:5))
> >
> > > rm(a)
> >
> > Obviously this wouldn't work, as it would only remove the object a.
> >
> > But is there any way I could do this, like on the lines of a UNIX `
> > (grave-accent)
> >
> > Something like
> >
> > Prompt> rm `find . -type f -name "foo"`
> >
> > TIA and best,
> > -Tir
> >
> > ______________________________________________
> > 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.
>
> --
> Csardi Gabor <csardi_at_rmki.kfki.hu> MTA RMKI, ELTE TTK

-- 
Csardi Gabor <csardi_at_rmki.kfki.hu>    MTA RMKI, ELTE TTK

______________________________________________
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.
Received on Wed 09 May 2007 - 09:49:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 May 2007 - 10:31:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.