Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aetiologicCanada/00184930bd5ca56f6d2a7ff6202a9d7c to your computer and use it in GitHub Desktop.
Save aetiologicCanada/00184930bd5ca56f6d2a7ff6202a9d7c to your computer and use it in GitHub Desktop.
fst looses a variable class on write_fst and/or read_fst
library(fst)
library(fs)
# name a list of files
#
initial_list_of_files <- fs::dir_info("~") %>% select(path, size)
class(initial_list_of_files)
head(initial_list_of_files)
# now store that
temporary_file_name <- tempfile()
fst::write_fst(initial_list_of_files, temporary_file_name)
# Now read that back in again
readbackin <-fst::read_fst(temporary_file_name)
# cant merge
merge_old_and_new <-dplyr::left_join(initial_list_of_files, readbackin, by="path")
# here are the classes:
class(initial_list_of_files$path)
class(readbackin$path)
# lost the "fs_path" class on write_fst and/or read_fst. Only kept "character"
# Desired outcome: keep both paths from initial_input.
#
@aetiologicCanada
Copy link
Author

at line 26 add:
class(readbackin$path) <- class(initial_list_of_files$path)
merge_old_and_new <-dplyr::left_join(initial_list_of_files, readbackin, by="path")

that works. Still a minor irritant in the otherwise marvelous fst package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment