I see this has been solved but here is a dplyr
/rlang
specific suggestion: you can use the .data
pronoun cf this dplyr
vignette,
"If this function is in a package, using
.data
also preventsR CMD check
from giving a NOTE about undefined global variables (provided that you’ve also importedrlang::.data
with@importFrom rlang .data
)."
dens <- data.frame(stats::density(x, n=2^10, adjust=1)[c("x","y")]) %>%
dplyr::mutate(section = cut(.data$x, breaks=breaks)) %>%
dplyr::group_by(.data$section) %>%
dplyr::mutate(prob = paste0(round(sum(.data$y)*mean(diff(.data$x))*100),"%"))
Note that I don't think the code you posted generates the NOTE for prob
, you must use prob
somewhere else as well?