1

I am making an R-Package and I'm struggling with the imports in a way that pleases R CMD check. It gives me the no visible binding for global variable '.' Note.

I went searching and found this answer, which seems like the best way to deal with the issue. But it raises a new problem since I can't seem to figure out how to use the rlang .data feature in conjunction with the . from magrittr.

Here is some nice and working code: tibble(A=0:10,B=10:20) %>% .$A Now I'd like to change it to use the rlang .data feature. Something like this tibble(A=0:10,B=10:20) %>% .data$A exept that it's not working : Error in .$.data : 3 arguments passed to '$' which requires 2

How can I use the .data feature in conjunction with the . from magrittr? Or to put it more abstract: What is the best way to get rid of R CMD check no visible binding for global variable '.' Note?

Someone2
  • 421
  • 2
  • 15

1 Answers1

0

.data won't help here: it solves the problem for data masking, which is not what's happening with . (see also dplyr . and _no visible binding for global variable '.'_ Note in package check).

I believe you have two choices: either don't use . inside the package, or follow this answer and add

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

as a top-level call somewhere in your package source.

Mikko Marttila
  • 10,972
  • 18
  • 31