R 管道工 API:如何指定输入类型?
R plumber APIs: How do I specify input types?
我有一个水管工API。
#* API title
#* @param param1
#*
#* @post /method_name
function(x) x
默认行为是将 param1
转换为字符串,然后我需要在函数体中使用 as.numeric(x)
。有没有办法指定每个参数的输入类型?如果我有 40 个参数,所有参数都是数字,有没有办法将每个参数都指定为数字?
您可以使用 param:type
设置特定参数的类型。假设你希望 param1
是一个整数,那么我们可以这样做:
#* API title
#* @param param1:int
#*
#* @post /method_name
function(x) x
我不知道如何以自动方式指定 40 个参数,而不仅仅是 #* @param paramx:int
对从 1 到 40 的 x 重复。您可以在 [=15= 中查看有关类型的详细信息] plumber
.
我有一个水管工API。
#* API title
#* @param param1
#*
#* @post /method_name
function(x) x
默认行为是将 param1
转换为字符串,然后我需要在函数体中使用 as.numeric(x)
。有没有办法指定每个参数的输入类型?如果我有 40 个参数,所有参数都是数字,有没有办法将每个参数都指定为数字?
您可以使用 param:type
设置特定参数的类型。假设你希望 param1
是一个整数,那么我们可以这样做:
#* API title
#* @param param1:int
#*
#* @post /method_name
function(x) x
我不知道如何以自动方式指定 40 个参数,而不仅仅是 #* @param paramx:int
对从 1 到 40 的 x 重复。您可以在 [=15= 中查看有关类型的详细信息] plumber
.