参数函数取决于第一个参数

时间:2018-07-09 14:16:37

标签: r function

可以附加取决于arg1的arg2的默认值吗?

my_function <- function(arg1=df,
arg2=as.numeric(paste0(format(as.Date(max(df$myDate)),"%Y%m"),"01"))){

df2<-arg1[(arg1$myDate>=arg2),]
}

当我将他的值附加在arg2或corps中时,我没有相同的结果。例如:

 my_function <- function(arg1=df){

arg2=as.numeric(paste0(format(as.Date(max(df$myDate)),"%Y%m"),"01"))
df2<-arg1[(arg1$myDate>=arg2),]
}

0 个答案:

没有答案