Another way to build functions "from scratch" :
> func<-'x^2+5'
> funcderiv<- D(parse(text=func), 'x') )
> newtparam <- function(zvar) {}
> body(newtparam)[2] <- parse(text=paste('newz <-
(',func,')/eval(funcderiv)',collapse=''))
> body(newtparam)[3] <- parse(text=paste('return(invisible
1] 2
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of honeyoak
> Sent: Wednesday, October 05, 2011 7:57 AM
> To: r-help@r-project.org
> Subject: [R]
On 05/10/2011 10:57 AM, honeyoak wrote:
it is possible to dynamically create functions in R using lists? what I want
to do is something like this:
a = list()
for (i in 1:10) a[[i]] = function(seed = i) runif(seed)
so that when I call a[i] I get random draws 1,2,i unfortunately
Hi,
On Wed, Oct 5, 2011 at 10:57 AM, honeyoak wrote:
> it is possible to dynamically create functions in R using lists? what I want
> to do is something like this:
>
> a = list()
> for (i in 1:10) a[[i]] = function(seed = i) runif(seed)
>
> so that when I call a[i] I get random draws 1,
it is possible to dynamically create functions in R using lists? what I want
to do is something like this:
a = list()
for (i in 1:10) a[[i]] = function(seed = i) runif(seed)
so that when I call a[i] I get random draws 1,2,i unfortunately R only
uses the last i . I would also like
5 matches
Mail list logo