I'm getting an error which seems wrong when running check(), not sure how to fix this or if it's a bug?
The error is
Running examples in ‘slfhelper-Ex.R’ failed
The error most likely occurred in:
> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: get_anon_chi
> ### Title: Match on anon_chi to a dataset using CHI numbers
> ### Aliases: get_anon_chi
>
> ### ** Examples
>
> get_anon_chi(data)
Error in UseMethod("left_join") :
no applicable method for 'left_join' applied to an object of class "function"
Calls: get_anon_chi ... freduce -> withVisible -> <Anonymous> -> <Anonymous>
Execution halted
The function is below, the function works and if I run the examples in a clean environment they work fine too. The return of read_fst is a tibble but devtools seems to see it as a function.
#' Match on anon_chi to a dataset using CHI numbers
#'
#' @param data tibble or data frame
#' @param chi_var CHI variable: the name of the variable containing CHI (default is chi)
#' @param drop Optional boolean indicating whether the existing chi_var should be dropped - default is TRUE
#'
#' @return a tibble
#' @export
#'
#' @examples
#' get_anon_chi(data)
#' get_anon_chi(data, drop = FALSE)
#' get_anon_chi(data, chi_var = "unique_id")
get_anon_chi <- function(data, chi_var = "chi", drop = TRUE) {
default_name <- "chi"
anon_chi_lookup <- fst::read_fst(
"<FILE PATH>/CHI-to-Anon-lookup.fst"
)
data <- data %>%
dplyr::left_join(
anon_chi_lookup,
by = setNames(default_name, chi_var)
)
if (drop) {
data <- data %>%
dplyr::select(-{{ chi_var }})
}
return(data)
}