Re: [R] object names from character strings

2010-12-26 Thread jim holtman
Consider storing the dataframes in a list so that you do not have to
create unique names and it will also give you better control by
keeping all the data together in one object.

On Sun, Dec 26, 2010 at 4:04 AM, Jim Bouldin  wrote:
> I realize this is probably pretty basic but I can't figure it out.
>
> I'm looping through an array, doing various calculations and producing a
> resulting data frame in each loop iteration.  I need to give each data frame
> a different name.  Although I can easily create a new character string for
> writing each frame to an output file, I cannot figure out how to convert
> such strings to corresponding object names within the R workspace itself, so
> as to give each d.f. a distinct name.  The closest I got were various
> attempts with the as.name function, but couldn't get that to work either.
>  Any help appreciated.  Thanks.
>
> --
> Jim Bouldin, PhD
> Research Ecologist
>
> __
> 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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?

__
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] object names from character strings

2010-12-26 Thread David Winsemius


On Dec 26, 2010, at 4:04 AM, Jim Bouldin wrote:


I realize this is probably pretty basic but I can't figure it out.

I'm looping through an array, doing various calculations and  
producing a resulting data frame in each loop iteration.  I need to  
give each data frame a different name.  Although I can easily create  
a new character string for writing each frame to an output file, I  
cannot figure out how to convert such strings to corresponding  
object names within the R workspace itself, so as to give each d.f.  
a distinct name.  The closest I got were various attempts with the  
as.name function, but couldn't get that to work either.  Any help  
appreciated.  Thanks.


Here's the first example in the help(assign) page:

or(i in 1:6) { #-- Create objects 'r.1', 'r.2', ... 'r.6'
   nam <- paste("r",i, sep=".")
  assign(nam, 1:i) }
ls(pattern = "^r..$")




--
Jim Bouldin, PhD
Research Ecologist

__
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.


David Winsemius, MD
West Hartford, CT

__
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] object names from character strings

2010-12-26 Thread Jim Bouldin

I realize this is probably pretty basic but I can't figure it out.

I'm looping through an array, doing various calculations and producing a 
resulting data frame in each loop iteration.  I need to give each data 
frame a different name.  Although I can easily create a new character 
string for writing each frame to an output file, I cannot figure out how 
to convert such strings to corresponding object names within the R 
workspace itself, so as to give each d.f. a distinct name.  The closest 
I got were various attempts with the as.name function, but couldn't get 
that to work either.  Any help appreciated.  Thanks.


--
Jim Bouldin, PhD
Research Ecologist

__
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.