I think this query fits better on r-package-devel rather than here. Bert Gunter
"The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Mar 24, 2021 at 6:07 AM Jeremie Juste <jeremieju...@gmail.com> wrote: > Hello, > > I was wondering how to call a function outside a setRefClass but inside > the package without export it. Let me explain by means of an example. > > - in the file test-package/R/test.R > > ##' some description > ##' > ##' some details > ##' @title test > ##' @return sideeffect > ##' @author Jeremie Juste > ##' @export test > ##' @import data.table > test <- setRefClass("test", > list(dt="data.table")) > > > test$methods( > > initialize = function(x){ > dt <<- remove_if_all_na(x[,abc:=1]) > } > ) > > > ##' remove rows for which all values are NA > ##' > ##' @title remove_if_all_NA > ##' @param dt > ##' @return dt > ##' @author Jeremie Juste > remove_if_all_NA <- function(dt) { > cn <- colnames(dt) > dt[!dt[NA],on=cn] > } > > > Here when I build and install the package test-package, if I don't export > remove_if_all_NA > > ##' remove rows for which all values are NA > ##' > ##' @title remove_if_all_NA > ##' @param dt > ##' @return dt > ##' @author Jeremie Juste > ##' @export > remove_if_all_NA <- function(dt) { > cn <- colnames(dt) > dt[!dt[NA],on=cn] > } > > The package cannot use it. > > library(test-package) > library(data.table) > > > aa <- data.table(a=1:10,b=letters[1:10]) > > b <- test(aa) > Error in remove_if_all_na(x[, `:=`(abc, 1)]) : > could not find function "remove_if_all_na" > > Do you have any recommendations? The official documentation for > setRefClass is a bit thin for me but I wanted to use a tools that is going > to stay. Any tip is > welcome. > > Best regards, > Jeremie > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.