【发布时间】:2026-01-25 02:40:01
【问题描述】:
如何动态调用 R6 方法,即方法名称作为字符串变量保存:
Test <- R6Class("Test",
public = list(
char_to_upper = function(var) { toupper(var) }
))
# create test object
test_obj <- Test$new()
# method name store in variable
method_to_call <- "char_to_upper"
# call method
test_obj$method_to_call("hello")
【问题讨论】: