如何通过opencpu将未知数量的参数传递给R函数?

如何通过opencpu将未知数量的参数传递给R函数?,r,R,我有这个R函数。第一个参数是json数据对象。我将json对象转换为数据帧,然后根据给这个函数的其他参数,根据给定的参数对数据帧进行子集划分。参数可以是dataframe中列名的全部或子集,因此会有所不同 转换为自定义json数据 我需要调用我的数据函数 data(x, "DateTime","Server1") 改天吧: data(x, "Datetime", "Server1", "Server2&q

我有这个R函数。第一个参数是json数据对象。我将json对象转换为数据帧,然后根据给这个函数的其他参数,根据给定的参数对数据帧进行子集划分。参数可以是dataframe中列名的全部或子集,因此会有所不同

转换为自定义json数据 我需要调用我的数据函数

data(x, "DateTime","Server1")
改天吧:

data(x, "Datetime", "Server1", "Server2")
是否有方法传递函数参数列表

例如:

arg_list<-c("DateTime", "Server1", "Server3")

data(x, arg_list)
 PlottList<-list(x=rnorm(10), y=rnorm(10), col="red",pch=16, xlab="X",ylab="Y")
 do.call(plot, PlotList)

arg\u list这里最简单的方法是将列名作为
列表传递。然后,您可以编写函数,这样无论列表中有多少个元素,它都可以工作,您甚至可以测试列表是否为
NA
,并对此做出适当的响应

至于传递参数的问题,参数可以以列表的形式传递给函数。这适用于
do.call
,例如:

arg_list<-c("DateTime", "Server1", "Server3")

data(x, arg_list)
 PlottList<-list(x=rnorm(10), y=rnorm(10), col="red",pch=16, xlab="X",ylab="Y")
 do.call(plot, PlotList)

这很好。我只有一个问题。当你设计你的函数时,你如何使它成为一个列表?xSure,你可以列出清单,我推荐。您还可以将其设置为
x
  PlottList2<-list( y=rnorm(10), col="red",pch=16, xlab="X",ylab="Y")
   do.call(plot,c(list(x=rnorm(10)),PlotList2))