Search code examples
rdataframelapplyfst

How to apply write_fst() function to each dataframe in list?


I want to save each dataframe from list with its according names as .fst file. My list with dataframes is called tables. I tried to do this, but it didn't work:

lapply(write_fst(), tables)

How to do that? How to perform write_fst function to each dataframe in list?


Solution

  • You can try using Map -

    Map(write_fst, tables, names(tables))
    

    If the names of the list do not have extension (.fst) you can use paste0 to add it.

    Map(write_fst, tables, paste0(names(tables), '.fst'))