Displaying 4 results from an estimated 4 matches for "funlist".
Did you mean:
unlist
2007 Oct 25
3
Deparsing part of a list argument
Here's a simple example of the type of function I'm trying to write,
where the first argument is a list of functions:
myfun <- function(funlist, vec){
tmp <- lapply(funlist, function(x)do.call(x, args = list(vec)))
names(tmp) <- names(funlist)
tmp
}
> myfun(list("Summation" = sum, prod, "Absolute value" = abs), c(1, 4, 6, 7))
$Summation
[1] 18
[[2]]
[1] 168
$`Absolute value`
[1] 1 4 6 7
What...
2004 Apr 05
3
Evaluation of functionals
Suppose I have
f1 <- function(x) x
f2 <- function(x) x^2
funlist <- list(f1,f2)
Then I would like to evaluate funlist such that when x is 10 I should get a list with 10 and 100.
A naive way of doint this is
myf <- funlist[[1]]
do.call(paste(quote(myf)), list(x=10))
myf <- funlist[[2]]
do.call(paste(quote(myf)), list(x=10))
- but there...
2010 Jan 27
1
returning a list of functions
Hi interested readers,
I have a function that creates several functions within a loop and I would like
them to be returned for further use as follows:
Main.Function(df,...){
# df is a multivariate data
funcList<-list(NULL)
for (i in 1:ncol(df)){
temp<-logspline(df[,i],...) # logspline density estimate
funcList[[i]]<-function(x){expression(temp,x)}
}
return(funcList)
}
I have tried
2009 May 19
4
Qs: The list of arguments, wrapping functions...
Hi. I'm pretty new to R, but I've been programming in other languages for
some time. I have a couple of questions regarding programming with function
objects.
1. Is there a way for a function to refer generically to all its actual
arguments as a list? I'm thinking of something like the @_ array in Perl or
the arguments variable in JavaScript. (By "actual" I mean the ones