【发布时间】:2021-11-22 17:27:31
【问题描述】:
有没有办法访问 R6 方法的参数?
例如,我可以通过以下方式访问rstan::stan() 的参数:
library(rstan)
formalArgs(rstan::stan)
#> [1] "file" "model_name" "model_code" "fit"
#> [5] "data" "pars" "chains" "iter"
#> [9] "warmup" "thin" "init" "seed"
#> [13] "algorithm" "control" "sample_file" "diagnostic_file"
#> [17] "save_dso" "verbose" "include" "cores"
#> [21] "open_progress" "..." "boost_lib" "eigen_lib"
但是,cmdstanr 使用 R6 类。
所以我可以通过查看$sample() 方法的所有参数
随附的帮助页面(``?cmdstanr::model-method-sample\``)。
但我似乎找不到以相同方式访问参数的方法。
例如,这会失败:
# remotes::install_github("stan-dev/cmdstanr")
library(cmdstanr)
formalArgs(cmdstanr::`model-method-sample`)
#> Error: 'model-method-sample' is not an exported object from 'namespace:cmdstanr'
有没有办法访问 R6 方法的形式参数?
由reprex package (v2.0.1) 于 2021 年 11 月 22 日创建
【问题讨论】: