r - 如何在R中的data.frame中添加文档?

标签 r dataframe

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

我想向数据框添加信息,例如由?iris显示(描述虹膜数据框中的数据)

但是,我找不到办法。

最佳答案

@Spacedman对于这种事情有很好的一般答案。

如果您想要一些更高级的产品,可以尝试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中各个列的机制。然后,在同一包中的contents()汇总您附加到data.frame的所有这些属性。

关于r - 如何在R中的data.frame中添加文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7919618/

相关文章:

r - 按列名称动态索引数据框

r - Data.frame 使用来自另一个 data.frame(如 Excel "criteria table")的条件转换数据

r - 如何使用 POSIXct 类型的列初始化 data.frame?

r - 剪接R中的bquote

r - 如何使内联 r 脚本在 RMarkdown 报告中可见?

python - 多索引数据帧的基于整数的 (K,N) 索引

python - 使用pandas DataFrame,我如何保持每7行?

python - 如何计算在数据框python中的特定值之前出现的次数?

r - Cbind 两个数据,但使用 data.table 进行了一些修改

r - 用散点图覆盖分组条形图