Martin Møller Skarbiniks Pedersen
2021-Mar-05 13:25 UTC
[R] "global parameter" warning using data.table in package.
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]]
Martin Møller Skarbiniks Pedersen
2021-Mar-05 13:26 UTC
[R] "global parameter" warning using data.table in package.
Please ignore my previous email. I just found the R-package-devel mailing list. On Fri, 5 Mar 2021 at 14:25, Martin M?ller Skarbiniks Pedersen < traxplayer at gmail.com> wrote:> 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 >-- Til uvedkommende, der l?ser med: Der er ingen grund til at l?se min mail. Jeg har intet at g?re med FARC, al-Jihad, al-Qaida, Hamas, Hizb al-Mujahidin eller ETA. Jeg har aldrig gjort Zakat, g?r ikke ind for Istishad, har ikke lavet en bilbombe eller kernev?ben og jeg ved d?rligt nok, hvad Al Manar og ????? betyder. Men tak for den udviste interesse. Leve Ligemageriet! Styrk p?belv?ldet! Bevar misundelsesafgifterne og cafepengene! Hurra for ?ldrebyrden! [[alternative HTML version deleted]]
Bert Gunter
2021-Mar-05 15:28 UTC
[R] "global parameter" warning using data.table in package.
I believe these questions belong on r-package-devel, not 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 Fri, Mar 5, 2021 at 5:25 AM Martin M?ller Skarbiniks Pedersen < traxplayer at gmail.com> wrote:> 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-help at 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]]