no visible binding for global variable ‘.’

Hi All,

I'm currently co-developing an R package using devtools. We use the
tidyverse %>% and associated purrr and dplyr packages within our

One of our functions is as follows (edited for clarity):

#' Print `cust_modl` object
#' @param x A `cust_modl` object.
#' @param ... Additional arguments passed to `print.cust_modl()` to print the
#'   object.
#' @method print cust_modl
#' @export
print.cust_modl <- function(x, ...) {

req_var_nms <- x$var %>%
purrr::compact(.x = .) %>%
names(x = .)

comp_var_ind_filt <- req_var_nms %>%
purrr::map(.x = ., .f = ~ purrr::pluck(x$var, .x))


This is currently giving an NOTE in our Github Actions devtools::check() as:

print.cust_modl: no visible binding for global variable ‘.’

I understand that this error is due to rlang related issues based on this helpful post
by @maelle. So typically we use @importFrom rlang .data as suggested and ensure
that in dplyr we carry the .data$ syntax correctly when referencing columns.

However, it seems that this NOTE was being given by the purrr calls and it is not
clear how to correct the rlang import for just the . (rather than the usual more explicit
.data call in dplyr).

Could anyone please explain how to correctly adjust R package code for the . as called by
tidyverse packages such as purrr? Understanding the recommended guidelines here
would allow our package to be developed to community standards.

Many thanks

Update: This is now cross-posted here since it hasn't received a reply in a few days.

Why use the dot at all? Genuine question, wouldn't the code below work

req_var_nms <- x$var %>%
purrr::compact() %>%

comp_var_ind_filt <- req_var_nms %>%
purrr::map(.f = ~ purrr::pluck(x$var, .x))
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.