#create package
devtools::create("./brainy",rstudio=F)
usethis::use_package("dplyr", type = "import", min_version = TRUE) ## set dependancy
I've a small function where I use %>%
from dplyr
. Also I use .
when piping. I do not know where is .
imported from or how to achieve its alignment when check()
ing the package
My small R code looks like in :
add<-function(x,y){
#' Package provides sample data that are loaded with package loading.
#' @param a and y are variables
#' #not RUN
#' @importFrom dplyr %>%
data_test<-data.frame(ID=c(seq(1:10)), NAME=c(paste("ID",seq(1:10),sep="_")))
data_test$NAME<-data_test$NAME %>% gsub("_*","",.) # for getting warning about .
return(x+y)
}
There is a test data I create for asking the question and to reproduce it.
I run following things:
devtools::document()
devtools::check()
I get warning as:
add: no visible binding for global variable ‘.’
Undefined global functions or variables:
.
How do I set my code where it achieves agreement with check()
with the .
. The resource below suggests to put into the globalVariables, but where (function, file) do I set the global variable at?
Hopefully, last question - which of the following should I use and why:
usethis::use_package("dplyr", type = "Depends", min_version = TRUE)
usethis::use_package("dplyr", type = "import", min_version = TRUE)
https://www.r-bloggers.com/no-visible-binding-for-global-variable/
Tool versions
dplyr_1.0.0
usethis_1.6.1
devtools_2.3.1
rmarkdown_2.3
R 4.0.0 (2020-04-24)