Search code examples
rdata.tablelintr

Import from `.` `data.table` so that lintr recognizes it


When running lintr on an R function that uses data.table I get the following warning:

warning: no visible global function definition for '.', Did you mean '-'?  

I thought an easy fix would be adding importFrom data.table .. I also tried quoting the dot with a backtick but it really doesn't seem to be exported. What is the recommened way to get of this error?

I could add the line

`.` <- function(){}

somewhere but I didn't get that to work and it's hacky.


Solution

  • What if you try quoting the dot with double quotes? importFrom data.table "."

    I know this is how I've done imports for the magrittr pipe operator

    If that doesn't work you can always add the . to a globals.R file that defines your global variables using utils::globalVariables()

    if(getRversion() >= "2.15.1")  utils::globalVariables(c("."))