Still I haven't had any luck yet.
How about defining new function and its domain, is it somehow possible?
Like this:
a<-function(x) x beolongs to natural numbers <0,100>
--
View this message in context:
http://r.789695.n4.nabble.com/filling-array-with-functions-tp3468313p3473300.html
Sent from th
On Apr 25, 2011, at 12:15 , derek wrote:
> Richard,
>
> that way I will have to write functions manually and that is not possible
> for large number of functions.
>
Well do what he means:
fv <- vector("list",10)
for (i...
{
...
fv[[i]] <- ...
...
}
(Your code still won't work as writt
Richard,
that way I will have to write functions manually and that is not possible
for large number of functions.
derek
--
View this message in context:
http://r.789695.n4.nabble.com/filling-array-with-functions-tp3468313p3472885.html
Sent from the R help mailing list archive at Nabble.com.
__
Derek,
You need a list.
f1 <- function(x) sin(x)
f2 <- function(x) cos(x)
f.list <- list(f1, f2)
f.list[[1]](pi)
f.list[[2]](pi)
## Note the double '[[' indexing.
## You can dimension a list to allow multiple-index indexing.
dim(f.list) <- c(2,1)
f.list[[1,1]](pi)
Rich
On Sun, Apr 24, 2011 a
Thats not exactly what I hoped for. But for now it has to suffice. More
transparent syntax would be nicer.
Exactly what I would like to do is:
for (i in 1:9){
f[i]<-function(x){
a*x+b)
}
curve(f[i], 0, 8)
sol[i]<-uniroot(f[i],c(0, 8))$root
points(sol[i],0,pch=16,cex=1,col="red")
}
Perhaps is
On Fri, 2011-04-22 at 10:02 -0700, derek wrote:
> Hello R,
>
> I would like to find out how to generate array full of functions. I tried it
> like this:
>
> fv=array(,dim=c(1,10))
> V=c(1:10)
> for (i in 1:10){
> fv[i]<-function(x)(V[i]-b*a*x) # b, x are constants.
> }
>
> But it returns:
> "inc
6 matches
Mail list logo