Pass string into map_dfr to filter using tidyfst

96 views Asked by At

I'm reading data stored in several fst-files using tidyfst and purrr::map_dfr. The following example works as expected.

library(tidyverse)
library(fst)
library(tidyfst)

# get all fst files in current directory
files_fst <- file.path(list.files(pattern = ".fst"))

df <- map_dfr(files_fst,
              ~ parse_fst(.) %>% 
                filter_fst(country == "France")) %>%
  bind_rows()

However, using a variable containing the string for which I want to filter does not work:

country_in <- "France"

df <- map_dfr(files_fst,
              ~ parse_fst(.) %>% 
                filter_fst(country == country_in)) %>%
  bind_rows()

Any ideas what's the problem here?

0

There are 0 answers