fst icon indicating copy to clipboard operation
fst copied to clipboard

attributes are not saved

Open OfekShilon opened this issue 2 years ago • 1 comments

Including row.names:

df <- data.frame(a=1:3,b=4:6)
rownames(df) <- c("row1","row2","row3")
df
#      a b
# row1 1 4
# row2 2 5
# row3 3 6
fst::write_fst(df,"~/tmp/df")
df2 <- fst::read_fst("~/tmp/df")
df2
#   a b
# 1 1 4
# 2 2 5
# 3 3 6

and class:

df <- data.table(a=1:3,b=4:6)
# [1] "data.table" "data.frame"
fst::write_fst(df,"~/tmp/df")
df2 <- fst::read_fst("~/tmp/df")
class(df2)
# [1] "data.frame"

OfekShilon avatar Jan 09 '23 13:01 OfekShilon

An "easy" way (avoid saving a list) to achieve this would be to first serialize the attributes in R via serialize(attributes(dt)) because then you only have to store a raw vector (which fst already supports) and later attributes(dt) = deserialize(attributesVec) them again in R.

ben-schwen avatar Jan 11 '24 22:01 ben-schwen