You can use the assign() function. E.g., assign("a", 3,)

But the more R thing to do is to create a list of your results (which
you can name) and to handle that whole object. Then if you want to do
things to each object you create, it's as simple as lapply

Michael

On Tue, Jan 24, 2012 at 7:27 PM, Philip Shirk <fil...@gmail.com> wrote:
> I've been struggling to get a loop to work.  I want to create a new
> variable in each loop with data from some function.
> for example:
>
> # part of the names for the variables to be created
> Frags <- c("F04", "F05", "F07", "F09", "F11", "F13", "F14", "F17", "F18",
> "F19", "P20", "Main")
>
> for(obs in Frags) {
>
> A.*obs* <- accumresult(Species, y=Environment, factor='Fragment',
>  level=*obs*, method='rarefaction', conditioned =T, gamma = 'boot' ,
>  permutations=100, scale='abundance')
>  P.*obs* <- accumplot(z,addit=FALSE, ci=2,ci.type='bar', col='1', cex=1,
>  xlab='abundance', pch=1, labels=*obs*)
> }
>
> The idea is to create variables such as A.F05 and P.F09, but of course this
> code isn't close to working, but I can't figure out how I SHOULD be doing
> it.
>
>
> Phil
>
>        [[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.

______________________________________________
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] loops Philip Shirk
    • Re: [R] loops R. Michael Weylandt

Reply via email to