USGS-R/drb-temp-data-release-v2

str_detect() - no applicable method for 'type' applied to an object of class "AsIs"

Closed this issue · 1 comments

filter(str_detect(string = filename, pattern = layer_name)) %>% pull(filename)

Getting the following error on the filter(str_detect()) part of this function.

files_to_zip <- data.frame(filepath = dir(dsn, full.names = TRUE), stringsAsFactors = FALSE) %>%
     mutate(filename = basename(filepath)) %>%
     filter(str_detect(string = filename, pattern = layer_name))

Error in `filter()`:
! Problem while computing
  `..1 = str_detect(string =
  filename, pattern =
  layer_name)`.
Caused by error in `UseMethod()`:
! no applicable method for 'type' applied to an object of class "AsIs"
Run `rlang::last_error()` to see where the error occurred.

suggestion changing to :

files_to_zip <- data.frame(filepath = dir(dsn, full.names = TRUE), stringsAsFactors = FALSE) %>%
     mutate(filename = basename(filepath)) %>%
     filter(grepl(pattern = layer_name, x = filename)) %>%
     pull(filename)

No longer an issue, Runs without a problem. Closing for now.