0

去年我在 R 中编写了一个 BaseX 客户端(https://github.com/BaseXdb/basex/tree/master/basex-api/src/main/r),现在我正在尝试为这个驱动程序构建一个包。
驱动程序是使用R6系统构建的。我将这些指令添加到RbaseXClient.R

#' @title RbaseX
#' @docType package
#' @name RbaseX
#' @description BaseX is a robust, high-performance XML database engine and a highly compliant XQuery 3.1 processor with full support of the W3C Update and Full Text extensions.
#' 
#' @importFrom magrittr %>%
#' @import dplyr
#' @import utils
#' @import R6
#' @import stringr
#' @import openssl

#' @export

使用以下代码初始化驱动程序:

initialize = function(host, port, username, password) {
  private$sock <- socketConnection(host = "localhost", port = 1984L,
    open = "w+b", server = FALSE, blocking = TRUE, encoding = "utf-8")
  private$response <- self$str_receive()
  splitted <-strsplit(private$response, "\\:")
  ifelse(length(splitted[[1]]) > 1,
         { code  <- paste(username, splitted[[1]][1],password, sep=":")
           nonce <- splitted[[1]][2]},
         { code  <- password
           nonce <- splitted[[1]][1]
         }
  )
  code <- md5(paste(md5(code), nonce, sep = ""))
  class(code) <- "character"
  private$void_send(username)
  private$void_send(code)
  if (!self$bool_test_sock()) stop("Access denied")}

第 4 行self$str_receive使用 magrittr pipe-operator %>%str_receive被定义为公共方法。
私有(第 15 行)方法中使用了相同的管道运算符,void_send但出现此错误:

Error in c(streamOut, c(0)) %>% as.raw() : could not find function "%>%"

如何使管道运算符(以及所有其他导入)可用于私有方法?

4

0 回答 0