list - R:提取 lm() 属性

标签 list r lm

我想从summary(lm())中提取fstatistic值。到目前为止我发现的唯一方法是

summary(lm(this_vector ~ that_vector))["fstatistic"][[1]][1]

是否有更简单的方法来获取该单元格值?这个问题有点迂腐,但我认为答案可能会提供一些有关如何使用 R 列表的有趣信息。

最佳答案

尝试以下任一方法:

summary(lm(this_vector ~ that_vector))$fstatistic[1]
summary(lm(this_vector ~ that_vector))[["fstatistic"]][1]

["fstatistic"] 返回一个列表,其中元素的名称与单括号内的内容匹配,因此您需要 [[1]] 来获取第一个元素。双括号返回元素本身,就像使用 $ 表示法一样。

关于list - R:提取 lm() 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8480876/

相关文章:

JQuery 将类添加到特定列表项

python - 索引值 16 的 list.index(value) 的值设置为 9

Python 排序和比较嵌套字典

r - Lapply 同时跳过特定列 R

r - 从日期列表中获取初始月份

R 数据帧 : Inter-row calculations

R 错误表示 "Models were not all fitted to the same size of dataset"

r - 如何用 ggplot 绘制 lm() 的残差?

r - 绘制数据框列表,每个数据框有 4 个变量

r - 在 R 中的 ggplot2 中外推散点图的线性拟合