[R] Applying function to lots of separate data sets
Spencer Graves
spencer.graves at pdf.com
Mon Sep 6 02:45:11 CEST 2004
Also, the underscore "_" in a legal character in a name in R 1.9
but not, I think in previous versions, where "_" translates to "<-".
Moreover, with at least some versions of ESS / Emacs / XEmacs, "_" is
translated into "<-" by (X)Emacs before it gets to R. hope this helps.
spencer graves
Duncan Murdoch wrote:
>On Mon, 6 Sep 2004 01:14:40 +0100 (BST), Laura Quinn
><laura at env.leeds.ac.uk> wrote:
>
>
>
>>I have a total mental block and can't find my way around this seemingly
>>simple problem:
>>
>>I have created a function such that:
>>
>>my_answer_1=myfuntion(my_input_1)
>>
>>I am wanting to perform this calculation over a large number of datasets,
>>but am having real difficulty calling and assigning - i think the problem
>>les in the fact that I need to paste for call and assign.
>>
>>this is my best attempt so far..I can't seem to find a way around this...
>>
>>for(i in 1:50)
>>eval(parse(text=paste("my_answer_",i,
>> "<-myfunction(text=paste("my_input_",i,sep=""))",sep="")))
>>
>>can someone please point out where i am going wrong?
>>
>>
>
>Using paste() to construct variable names is overdone. It's much
>better to put all of your data into a list in one object, then just
>use lapply() to apply a function to each element of the list.
>
>For examples, see ?lapply.
>
>Duncan Murdoch
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
--
Spencer Graves, PhD, Senior Development Engineer
O: (408)938-4420; mobile: (408)655-4567
More information about the R-help
mailing list