最佳答案
当在 R中使用 lapply时,我有一个关于向函数传递多个参数的问题。
当我使用 lapplication 和 lapply(input, myfun);的语法时——这很容易理解,我可以这样定义 myfun:
myfun <- function(x) {
# doing something here with x
}
lapply(input, myfun);
和 input的元素作为 x参数传递给 myfun。
但是,如果我需要向 myfunc传递更多的参数,该怎么办呢? 例如,它的定义是这样的:
myfun <- function(x, arg1) {
# doing something here with x and arg1
}
如何使用这个函数同时传递 input元素(作为 x参数)和其他参数?