我正在编写一个使用 tidyverse 函数的包,即使用非标准评估,dplyr::filter
例如:
setMethod("filter_by_id",
signature(x = "studies", id = "character"),
definition = function(x, id) {
study_id <- rlang::expr(study_id)
lst <- purrr::map(s4_to_list(x), ~ dplyr::filter(.x, !!study_id %in% id))
y <- list_to_s4(lst, "studies")
return(y)
})
我正在使用!!
运算符(我可能会使用rlang
包中的其他一些运算符),我想知道是否需要像使用 pipe-operator 一样显式导入它%>%
,如以下问题所述:R: use magrittr pipe operator in自写包。
有没有相当于usethis::use_pipe()
但是对于来自的运营商的东西rlang
?