Created
November 30, 2018 00:19
-
-
Save aetiologicCanada/00184930bd5ca56f6d2a7ff6202a9d7c to your computer and use it in GitHub Desktop.
fst looses a variable class on write_fst and/or read_fst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.