Dear Rolf, utils::globalVariables() seems to work package wide. I prefer to ignore these variable only within the function in which I explicitly define them. If I use one of those variables in another function in which I haven't declared them as global, then I want R CMD check to give me a NOTE.
Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2015-05-28 11:28 GMT+02:00 Rolf Turner <r.tur...@auckland.ac.nz>: > On 27/05/15 23:37, Thierry Onkelinx wrote: > >> Dear Glenn, >> >> Suppose this function >> >> test <- function(df){ >> ggplot(df, aes(x = gp, y = y)) + geom_point() >> } >> >> Then R CMD check will consider gp and y as global variables since they are >> undefined. Because R CMD check cannot detect that gp and y will be >> extracted from df by ggplot2. >> >> Possible workarounds >> >> # now gp and y are defined within the function. ggplot2 still looks for gp >> and y in df. >> test <- function(df){ >> gp <- NULL >> y <- NULL >> ggplot(df, aes(x = gp, y = y)) + geom_point() >> } >> >> # now "gp" and "y" are strings and hence defined >> test <- function(df){ >> ggplot(df, aes_string(x = "gp", y = "y")) + geom_point() >> } >> > > <SNIP> > > Why not use utils::globalVariables? > > cheers, > > Rolf Turner > > -- > Technical Editor ANZJS > Department of Statistics > University of Auckland > Phone: +64-9-373-7599 ext. 88276 > [[alternative HTML version deleted]] ______________________________________________ R-help@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.