我有以下功能:
example_Foo <- function( ...,FigureFolder){
# check what variables are passed through the function
v_names <- as.list(match.call())
variable_list <- v_names[2:(length(v_names)-2)]
# create file to store figures
subDir <- c(paste(FigureFolder,"SavedData",sep = "\\"))
}
显然这只是函数的开始,但我已经遇到了一些问题。在这里,我试图定义我最终希望保存结果的目录。使用该函数的一个例子是:
weight <- c(102,20,30,04,022,01,220,10)
height <- c(102,20,30,04,022,01,220,10)
catg <- c(102,20,30,04,022,01,220,10)
catg <- matrix(height,nrow = 2)
FigureFolder <- "C:\\exampleDat"
# this is the function
example_Foo(catg,FigureFolder)
这会产生以下错误:
Error in paste(FigureFolder, "SavedData", sep = "\\") :
argument "FigureFolder" is missing, with no default
我猜这是由于函数不知道'FigureFolder'是什么,我的问题是如何通过函数传递这个字符串?