如何从R中的帮助文件的“另请参见”部分提取函数名称?

时间:2012-02-12 00:20:14

标签: r cran

如何从帮助文件的“另请参阅”部分提取函数名称? 例如 : from object = help(lm) 来自“另请参阅”部分:

 ‘summary.lm’ for summaries and ‘anova.lm’ for the ANOVA table;
 ‘aov’ for a different interface.

 The generic functions ‘coef’, ‘effects’, ‘residuals’, ‘fitted’,
 ‘vcov’.

 ‘predict.lm’ (via ‘predict’) for prediction, including confidence
 and prediction intervals; ‘confint’ for confidence intervals of
 _parameters_.

我想有一个函数名称的向量 - “summary.lm”,“anova.lm”,“coef”......

1 个答案:

答案 0 :(得分:-1)

我认为这就是你想要的。使用模型名称周围的names函数以及summary(model.name)附近的名称:

mod <- lm(hp ~ mpg, data=mtcars)
names(mod)
names(summary(mod))
names(mod)[5] #extract just one name from the vector of names with indexing