[R-pkg-devel] Using data.table in a package

neonira Arinoem neon|r@ @end|ng |rom gm@||@com
Fri Mar 5 14:54:45 CET 2021


Question one is a matter of personal preference. I personally stick to
explicitly state a double column depency with data.table.

Question two. Just replacing the dot by list is sufficient AFAIK.

Hope this helps



Le ven. 5 mars 2021 à 14:28, Martin Møller Skarbiniks Pedersen <
traxplayer using gmail.com> a écrit :

> Hi,
>
>   I am converting a couple of functions into a R-package. Many of the
> functions use data.table.
>   I have two questions using data.table in my own package.
>   Normally I would put each question in separate emails but I think they
> might be connected.
>
> First question is short and I think the answer is yes.
> 1. Do I always need to prefix data.table each time I use something from
> that package?
> Eg. DT <- data.table::data.table(x=rep(c("b","a","c"),each=3), y=c(1,3,6),
> v=1:9)
>
> Second question is longer.
> 2.  In this small example code:
> hello <- function() {
>   DT <- data.table::data.table(x=rep(c("b","a","c"),each=3), y=c(1,3,6),
> v=1:9)
>   DT[, .(sum(v))]
> }
>
> I get these warnings from R CMD check:
> hello: no visible global function definition for ‘.’
> hello: no visible binding for global variable ‘v’
> Undefined global functions or variables:
>   . v
>
> According to: vignette("datatable-importing", package = "data.table")
> The solution is
> hello <- function() {
>   v <- NULL
>   . <- NULL
>
> And it works but looks a bit weird.
> Is there a better solution?
>
> Regards
> Martin
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list