Re: [R] Unique Data Frame Name?

From: Dennis Murphy <djmuser_at_gmail.com>
Date: Thu, 24 Jun 2010 00:19:26 -0700

Hi:

Try this:

> for (i in 1:2) {

+       x=c(1,2,3,4)
+       y=c(10,20,30,40)
+       G <- paste("name", i, sep="")
+       assign(G, data.frame(x,y))
+ }

> name1

  x y
1 1 10
2 2 20
3 3 30
4 4 40
> name2

  x y
1 1 10
2 2 20
3 3 30
4 4 40

HTH,
Dennis

On Wed, Jun 23, 2010 at 3:56 PM, Douglas M. Hultstrand <dmhultst_at_metstat.com
> wrote:

> Hello,
>
> I am trying to create a data frame with a unique name, based on indexing of
> for loop. I was wondering if there is a way to do this, I keep running into
> errors when I try to do this. Below is a brief example, I am trying to get
> two data frames (name1 and name2).
>
> Any suggestions are appreciated.
>
> Thanks,
> Doug
>
> # Example
> for (i in 1:2) {
> x=c(1,2,3,4)
> y=c(10,20,30,40)
> G <- paste("name", i, sep="")
> G[i] <- data.frame(x,y)
> }
>
> --
> ---------------------------------
> Douglas M. Hultstrand, MS
> Senior Hydrometeorologist
> Metstat, Inc. Windsor, Colorado
> voice: 720.771.5840
> email: dmhultst_at_metstat.com
> web: http://www.metstat.com
>
> ______________________________________________
> 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.
>

        [[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. Received on Thu 24 Jun 2010 - 07:23:58 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 Thu 24 Jun 2010 - 07:30:34 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.

list of date sections of archive