How to add “optional dataset description” to feather file?

放肆的年华 提交于 2020-03-26 04:27:45

问题


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"


来源:https://stackoverflow.com/questions/47896468/how-to-add-optional-dataset-description-to-feather-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!