How to add “optional dataset description” to feath

2019-08-18 08:04发布

问题:

The R-help for feather_metadata states "Returns the dimensions, field names, and types; and optional dataset description." but there is no information on how to add the data description. I hoped it could be added as an attribute but that doesn't seem to work.

library(feather)

dat <- data.frame(a = 1:3, b = 4:6)
attr(dat, "description") <- "A data.frame"
write_feather(dat,  "df.feather")
str(feather_metadata("df.feather"))

str returns:

List of 5
 $ path       : chr "df.feather"
 $ dim        : int [1:2] 3 2
 $ types      : Named chr [1:2] "integer" "integer"
  ..- attr(*, "names")= chr [1:2] "a" "b"
 $ description: chr ""
 $ version    : int 2
 - attr(*, "class")= chr "feather_metadata"

回答1:

I just submitted a PR for this functionality. If you are willing to install from source, you can install from https://github.com/hrbrmstr/feather and:

library(feather)

dat <- data.frame(a = 1:3, b = 4:6)

write_feather(dat,  "df.feather", "I am the very model of a modern major general")

str(feather_metadata("df.feather"))
##List of 5
## $ path       : chr "df.feather"
## $ dim        : int [1:2] 3 2
## $ types      : Named chr [1:2] "integer" "integer"
##  ..- attr(*, "names")= chr [1:2] "a" "b"
## $ description: chr "I am the very model of a modern major general"
## $ version    : int 2
##  - attr(*, "class")= chr "feather_metadata"


标签: r feather