本文介绍了如何向R中的data.frame添加文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用R一段时间,我已经意识到,如果您可以附加data.frame中包含的描述数据,这将有助于您,因为您可以在.Rdata文件中收集所有有用的研究信息。

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 research information in a .Rdata file.

我想添加到我的数据框信息,如?iris(描述io数据帧中的数据)显示的信息

I want to add to my dataframe info like the one is displayed by ?iris (describing the data in the iris dataframe)

但是我找不到这样做的方法。

However I cannot find a way to do this.

推荐答案

@ Spacedman对此有一个很好的一般答案的东西。

@Spacedman has the good general answer for this sort of thing.

如果你想要一点点爱好者,你可以试试 comment()。 / p>

If you'd like something a little fancier, you could try out comment().

 comment(iris) <-
 "     This famous (Fisher's or Anderson's) iris data set gives the
 measurements in centimeters of the variables sepal length and
 width and petal length and width, respectively, for 50 flowers
 from each of 3 species of iris.  The species are _Iris setosa_,
 _versicolor_, and _virginica_.\n"

 cat(comment(iris))
 # This famous (Fisher's or Anderson's) iris data set gives the
 # measurements in centimeters of the variables sepal length and
 # width and petal length and width, respectively, for 50 flowers
 # from each of 3 species of iris.  The species are _Iris setosa_,
 # _versicolor_, and _virginica_.

label() units() Hmisc 软件包提供了记录data.frames中各个列的机制。 content(),在同一个包中,然后总结您附加到data.frame的任何这些属性。

label() and units() from the in the Hmisc package provide mechanisms for documenting individual columns in data.frames. contents(), in the same package then summarizes any of these attributes you've attached to the data.frame.

这篇关于如何向R中的data.frame添加文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 21:25