为什么`R`中的`args()`总是打印方法的agruments?

时间:2017-02-15 11:48:12

标签: r

args()的功能是:

  

显示参数名称和a的相应默认值   功能或原始

args(subset)例如仅打印:

> args(subset)
function (x, ...) 
NULL

为什么它有时会起作用,有时候不会?

1 个答案:

答案 0 :(得分:3)

函数var jsonString = { comp_code: 100, comp_name: 'Test company', comp_url: 'Some url', comp_note: 'Some notes', comp_acc: '1002000' }; var myTemplate = `Code: ${jsonString.comp_code}, Name: ${jsonString.comp_name}, Company account: ${jsonString.comp_acc}`; console.log(myTemplate)是S3泛型方法

args()

所以当你运行subset #function (x, ...) #UseMethod("subset") #<bytecode: 0x1ee3ee0> #<environment: namespace:base> 时,你得到的是函数的参数 - 而不是你想要的函数。

S3泛型方法查看对象args(subset)的类并调度到另一个函数。要查看可用的功能,请使用x

methods()