[R] use value in variable to be name of another variable
Matthew
mccormack at molbio.mgh.harvard.edu
Tue Jul 12 00:34:26 CEST 2016
Hi Rolf,
Thanks for the warning. I think because my initial efforts used the
assign function, that Jim provided his solution using it.
Any suggestions for how it could be done without assign() ?
Matthew
On 7/11/2016 6:31 PM, Rolf Turner wrote:
> On 12/07/16 10:13, Matthew wrote:
>> Hi Jim,
>>
>> Wow ! And it does exactly what I was looking for. Thank you very
>> much.
>>
>> That assign function is pretty nice. I should become more familiar
>> with it.
>
> Indeed you should, and assign() is indeed nice and useful and handy.
> But it should be used with care and circumspection. It *alters the
> global environment* which is fraught with peril. Generally speaking
> most things that can be done with assign() (and its companion function
> get()) are better and more safely done using lists and functions and
> other "natural" R-ish constructs. Resist the temptation to turn R into
> a macro language.
>
> cheers,
>
> Rolf Turner
>
More information about the R-help
mailing list