gpt4 book ai didi

r - 从 heplots R 包获取 heplot 函数的参数

转载 作者:行者123 更新时间:2023-12-01 12:39:50 24 4
gpt4 key购买 nike

获取 R 函数的参数非常简单,可以通过 args(functionname) 提取。但是我不知道如何从 heplots 包中获取 heplot 函数的参数。

library(heplots)
?heplot
args(heplot)

function (mod, ...)
NULL

我想得到以下部分:

## S3 method for class 'mlm'
heplot(mod, terms, hypotheses, term.labels = TRUE,
hyp.labels = TRUE, err.label="Error", label.pos=NULL,
variables = 1:2, error.ellipse = !add,
factor.means = !add, grand.mean = !add, remove.intercept = TRUE,
type = c("II", "III", "2", "3"), idata=NULL, idesign=NULL,
icontrasts=c("contr.sum", "contr.poly"),
imatrix=NULL, iterm=NULL, markH0=!is.null(iterm),
manova, size = c("evidence", "effect.size"),
level = 0.68, alpha = 0.05, segments = 40,
center.pch = "+", center.cex=2,
col = getOption("heplot.colors",
c("red", "blue", "black", "darkgreen",
"darkcyan","magenta", "brown","darkgray")),
lty = 2:1, lwd = 1:2,
fill=FALSE, fill.alpha=0.3,
xlab, ylab, main = "", xlim, ylim, axes=TRUE, offset.axes,
add = FALSE, verbose = FALSE, warn.rank = FALSE, ...)

最佳答案

heplot 是一个 S3 通用函数。它使用方法 heplot.mlm,这是一个非导出函数。您可以首先查看 heplot 的函数体来访问该信息。如果您在函数体中看到 UseMethod,则该函数使用了一个方法。可以使用 methods

访问 S3 泛型函数的所有可用方法
> methods(heplot)

要访问非导出函数,您可以使用:::。用 args 包装那个调用,你就有了你正在寻找的参数列表。

> args(heplots:::heplot.mlm)
# function (mod, terms, hypotheses, term.labels = TRUE, hyp.labels = TRUE,
# err.label = "Error", label.pos = NULL, variables = 1:2, error.ellipse = !add,
# factor.means = !add, grand.mean = !add, remove.intercept = TRUE,
# type = c("II", "III", "2", "3"), idata = NULL, idesign = NULL,
# icontrasts = c("contr.sum", "contr.poly"), imatrix = NULL,
# iterm = NULL, markH0 = !is.null(iterm), manova, size = c("evidence",
# "effect.size"), level = 0.68, alpha = 0.05, segments = 40,
# center.pch = "+", center.cex = 2, col = getOption("heplot.colors",
# c("red", "blue", "black", "darkgreen", "darkcyan", "magenta",
# "brown", "darkgray")), lty = 2:1, lwd = 1:2, fill = FALSE,
# fill.alpha = 0.3, xlab, ylab, main = "", xlim, ylim, axes = TRUE,
# offset.axes, add = FALSE, verbose = FALSE, warn.rank = FALSE,
# ...)
# NULL

注意:这个函数显然有很多参数,所以

> formals(args(heplots:::heplot.mlm))  ## or as.list()

可能是一种更好、更易读的方式来遍历参数列表。

关于r - 从 heplots R 包获取 heplot 函数的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25905146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com