How to add documentation to a data.frame in R?

前端 未结 3 686
后悔当初
后悔当初 2021-01-30 07:08

I\'ve been using R for a while and I\'ve realized it would help a lot if you could attach a description data contained in the data.frame, because you could gather all useful res

3条回答
  •  伪装坚强ぢ
    2021-01-30 07:45

    You can add it as an arbitrary attribute:

    attr(df,"doc") = "This is my documentation"
    

    These things are mostly preserved by slicing n subsetting, but some processes will drop them. Such is the nature of a pass-by-value system.

    There may even be a package on CRAN for more complex metadata as attributes with some wrapper functions, but underneath its all attributes...

提交回复
热议问题