Re: [R] execute array of functions

2012-02-14 Thread Bert Gunter
Not sure the replies you received make it clear, but the key point is that functions are first class objects in R like any other objects (vectors, lists, data frames) and can be assigned, collected into structures, indexed, etc. in the usual way. Further, if the value of any R expression is a funct

Re: [R] execute array of functions

2012-02-14 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Nordlund, Dan (DSHS/RDA) > Sent: Tuesday, February 14, 2012 11:24 AM > To: r-help@r-project.org > Subject: Re: [R] execute array of functions > >

Re: [R] execute array of functions

2012-02-14 Thread Duncan Murdoch
On 14/02/2012 2:23 PM, Nordlund, Dan (DSHS/RDA) wrote: > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Muhammad Rahiz > Sent: Tuesday, February 14, 2012 11:03 AM > To: x.r-help > Subject: [R] execute

Re: [R] execute array of functions

2012-02-14 Thread David Winsemius
On Feb 14, 2012, at 2:32 PM, Stavros Macrakis wrote: That won't work because R has special rules for evaluating things in the function position. Examples: *OK* min(1:2) "min"(1:2) f<-min; f(1:2) do.call(min,list(1:2)) do.call("min",list(1:2)) # do.call converts string->function *Not

Re: [R] execute array of functions

2012-02-14 Thread David Winsemius
On Feb 14, 2012, at 2:23 PM, Nordlund, Dan (DSHS/RDA) wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Muhammad Rahiz Sent: Tuesday, February 14, 2012 11:03 AM To: x.r-help Subject: [R] execute array of functions Hi all

Re: [R] execute array of functions

2012-02-14 Thread Stavros Macrakis
That won't work because R has special rules for evaluating things in the function position. Examples: *OK* min(1:2) "min"(1:2) f<-min; f(1:2) do.call(min,list(1:2)) do.call("min",list(1:2)) # do.call converts string->function *Not OK* ("min")(1:2) # string in function positi

Re: [R] execute array of functions

2012-02-14 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Muhammad Rahiz > Sent: Tuesday, February 14, 2012 11:03 AM > To: x.r-help > Subject: [R] execute array of functions > > Hi all, > > I'm

[R] execute array of functions

2012-02-14 Thread Muhammad Rahiz
Hi all, I'm trying to get the min and max of a sequence of number using a loop like the folllowing. Can anyone point me to why it doesn't work. Thanks. type<- c("min","max") n <- 1:10 for (a in 1:2){ print(type[a](n)) } -- Muhammad