Re: [R] Remove objects names like character String

2009-05-19 Thread Ronggui Huang
I don't get the error you mention:

> site1_data<-1
> site2_data<-2
> site3_data<-3
> for (i in 1:3) paste("site",i,"_data",sep="")
>

In my example, another way is: rm(list=paste("site",1:3,"_data",sep=""))

Or you can use rm(list=ls(pattern=you pattern)), in my example, it is:
rm(list=ls(pattern="site[1-3]_data"))

Ronggui

2009/5/19 Katharina May :
> Hi,
>
> how can I use rm() on objects named like:
> paste("site",i,"_data",sep="") while looping
> through i?
> I tried rm(paste("site",i,"_data",sep="")) but I get the error that
> rm() must contain names or
> text strings which is confusing me as I thought paste() would create
> something like that...?
>
> Thanks,
>
>
>         Katharina
>
>
>
> --
> Time flies like an arrow, fruit flies like bananas.
>
> __
> R-help@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.
>



-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html

__
R-help@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.


Re: [R] Remove objects names like character String

2009-05-19 Thread Katharina May
thanks to all your solutions, works out perfectly!


2009/5/19 Henrique Dallazuanna :
> Try this:
>
> rm(list=ls(patt="site[0-9]$"))
>
> On Tue, May 19, 2009 at 7:47 AM, Katharina May
>  wrote:
>>
>> Hi,
>>
>> how can I use rm() on objects named like:
>> paste("site",i,"_data",sep="") while looping
>> through i?
>> I tried rm(paste("site",i,"_data",sep="")) but I get the error that
>> rm() must contain names or
>> text strings which is confusing me as I thought paste() would create
>> something like that...?
>>
>> Thanks,
>>
>>
>>         Katharina
>>
>>
>>
>> --
>> Time flies like an arrow, fruit flies like bananas.
>>
>> __
>> R-help@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.
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>



-- 
Time flies like an arrow, fruit flies like bananas.

__
R-help@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.


Re: [R] Remove objects names like character String

2009-05-19 Thread Henrique Dallazuanna
Try this:

rm(list=ls(patt="site[0-9]$"))

On Tue, May 19, 2009 at 7:47 AM, Katharina May  wrote:

> Hi,
>
> how can I use rm() on objects named like:
> paste("site",i,"_data",sep="") while looping
> through i?
> I tried rm(paste("site",i,"_data",sep="")) but I get the error that
> rm() must contain names or
> text strings which is confusing me as I thought paste() would create
> something like that...?
>
> Thanks,
>
>
> Katharina
>
>
>
> --
> Time flies like an arrow, fruit flies like bananas.
>
> __
> R-help@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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Remove objects names like character String

2009-05-19 Thread Uwe Ligges



Katharina May wrote:

Hi,

how can I use rm() on objects named like:
paste("site",i,"_data",sep="") while looping
through i?
I tried rm(paste("site",i,"_data",sep="")) but I get the error that
rm() must contain names or
text strings which is confusing me as I thought paste() would create
something like that...?



Well, I would try to avoid the creation of so many objects, but once you 
have them you can do even without a loop:


e.g. for the first 5:

i <- 1:5
do.call("rm", list(paste("site", i, "_data", sep="")))

Uwe Ligges



Thanks,


 Katharina





__
R-help@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.


[R] Remove objects names like character String

2009-05-19 Thread Katharina May
Hi,

how can I use rm() on objects named like:
paste("site",i,"_data",sep="") while looping
through i?
I tried rm(paste("site",i,"_data",sep="")) but I get the error that
rm() must contain names or
text strings which is confusing me as I thought paste() would create
something like that...?

Thanks,


 Katharina



-- 
Time flies like an arrow, fruit flies like bananas.

__
R-help@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.