0

I am building a package in R. The first function, is a ggplot function containing x and y for the definition of the x and y axis (aes(x,y)).

After running the command devtools::check(), I am receiving this message

"no visible binding for global variable 'x' "

even after adding @importFrom ggplot2 aes

I think that's because x and y are parameters for aes, but I don't know how to solve it.

Nad Pat
  • 3,129
  • 3
  • 10
  • 20
  • refer https://community.rstudio.com/t/how-to-solve-no-visible-binding-for-global-variable-note/28887 https://stackoverflow.com/questions/9439256/how-can-i-handle-r-cmd-check-no-visible-binding-for-global-variable-notes-when – Nad Pat Dec 07 '21 at 13:11
  • Actually yes, but I was searching another strategy because I don't find putting these parameters as NULL is very "logic". That's why I was looking for another way to fix it – Mayssa Harfouch Dec 07 '21 at 15:16
  • It feels somewhat 'hacky' but a workaround is a file in R, named globals.R or similar (up to you, but standard is globals.R), in which you call utils::globalVariables( c("name", "your", "variables"). Alternatively you can look into rlang::.data, but that's a bit out of scope here I feel. – jpenzer Dec 07 '21 at 15:27

0 Answers0