[R] Am I misunderstanding loop variable assignment or how to use print()?

Tony Stocker akostocker at gmail.com
Thu Dec 15 16:59:16 CET 2011


On Thu, Dec 15, 2011 at 10:54, Sarah Goslee <sarah.goslee at gmail.com> wrote:
>
> print(get(x)[["Pr"]]) maybe. Do the get(), then do the subsetting.
>
>
>>>
>>> It's often neater and more efficient to store your anova objects in a
>>> list, though.
>>
>> anything since it's still a set of character strings.  Could you
>> elaborate a bit on what you mean by storing the anova objects as
>> lists?
>
> Yes: not the names, but the anova objects themselves. Rather than
> creating a bunch of individual objects, store them in a list when
> created:
>
> myanova <- list()
> myanova[["ag.m2529.az"]] <- anova(whatever)
> myanova[["ag.m2529.can"]] <- anova(whatever)
> ...
>
> Then you can quite elegantly use lapply() across all of the anovas at once,
> and don't have so many objects in your workspace.

Okay I'll give that a try and see how it works for me.  Thanks for the
suggestion.



More information about the R-help mailing list