如何将字符作为R中函数的参数传递?
通常,我们可以在R中编写以下函数:如何将字符作为R中函数的参数传递?,r,R,通常,我们可以在R中编写以下函数: testFunc <- function(a) {a} # This returns the value of a 我们如何以这种方式获取testFunc: argName <- 'a' testFunc <- function(argName) {a} # This does not work, since argName is required in this function. argName#创建不带参数的函数 testFu
testFunc <- function(a) {a} # This returns the value of a
我们如何以这种方式获取testFunc:
argName <- 'a'
testFunc <- function(argName) {a} # This does not work, since argName is required in this function.
argName#创建不带参数的函数
testFunc对于a
作为testFunc Hi Bowen Chen中的返回值意味着什么,是否要返回默认参数?如果是这样,formals会执行此formals(testFunc)$a
argName <- 'a'
testFunc <- function(argName) {a} # This does not work, since argName is required in this function.
#create function without arguments
testFunc <- function() {a}
#add argument
argName <- 'a'
args <- alist(x = )
names(args) <- argName
formals(testFunc) <- args
testFunc
#function (a)
#{
# a
#}