0

我正在实现一个新的 R6Class 并尝试动态添加新成员(https://cran.r-project.org/web/packages/R6/vignettes/Introduction.html#adding-members-to-an-existing-class ) 但是当我实现 getx2 函数时,我得到了这个错误“__Deferred_Default_Marker__”(无论它是否是动态的)。

Simple <- R6Class("Simple",
                  public = list(
                     x = 1,
                     getx = function() self$x,
                     getx2 = function() return(self$x * 2)
                  )
)

# To replace an existing member, use overwrite=TRUE
Simple$set("public", "x", 10, overwrite = TRUE)

s <- Simple$new()
s$getx2() # this returns "__Deferred_Default_Marker__"

对此有什么想法吗?就像在文档中一样

4

1 回答 1

0

解决方案是更新软件包。以下指令的问题:

devtools::install_github('r-lib/R6', build_vignettes = FALSE)

它是否给我带来了以下错误:namespace 'R6' is imported by 'CompatibilityAPI', 'mrsdeploy' so cannot be unloaded"

所以我关闭了 RStudio,打开了 R.exe ( C:\Program Files\R\R-3.3.3\bin) 并运行了相同的命令。现在,我有这个包:

Package: R6
Version: 2.2.2.9000
URL: https://github.com/r-lib/R6/

它按照规范工作。

于 2018-02-23T22:26:23.940 回答