I use dplyr a lot in various functions which I am putting together into a package.
I am not supposed to use library(dplyr)
ever so I am trying to double colon everything. However I cannot seem to get the dplyr version right. When I do this for example:
SurveillanceLastToNow <- function(x, A_thing, Date) {
x %>% dplyr::arrange_(A_thing, Date) %>%
dplyr::group_by_(A_thing) %>% dplyr::mutate(diffDate = difftime(Sys.Date(),
last(Date), units = "days"))
}
I get the error:
could not find function "%>%"
So my questions are
- Do I need to
magrittr::%>%
all the way through?....surely not - Given how much I use
dplyr
, including most of its functions, how do I just load the whole thing on installing the package rather than::
everywhere
Basically I'm looking for the laziest way to use all the dplyr
functions in my package