0

Last year I have written a BaseX client in R (https://github.com/BaseXdb/basex/tree/master/basex-api/src/main/r) and now I am trying to build a package for this driver.
The driver is built, using the R6 system. I added these directives to 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

The driver is initialized with this code:

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")}

In line 4 self$str_receive uses the magrittr pipe-operator %>%. str_receive is defined as a public method.
The same pipe-operator is used in the private void_send (line 15) method but there I get this error:

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

How can I make the pipe-operator (and all the other imports) available to the private methods?

Ben

Alexis
  • 4,950
  • 1
  • 18
  • 37
Ben Engbers
  • 433
  • 3
  • 12
  • You also need to add the packages to `Imports` in `DESCRIPTION`. – Alexis Sep 02 '19 at 07:21
  • The roxygen directives in your first code block are not enough; you need to "compile" the documentation. This will ensure that the directives are inserted into your `DESCRIPTION` and `NAMESPACE` file in the package. – MrGumble Sep 02 '19 at 09:10

0 Answers0