简体   繁体   English

从 heplots R 包中获取 heplot 函数的参数

[英]Getting arguments of heplot function from heplots R package

Getting arguments of an R function is quite easy and can be extracted by args(functionname) .获取R函数的参数非常简单,可以通过args(functionname)提取。 But I could not figured out how to get the arguments of heplot function from heplots package.但是我不知道如何从heplots包中获取heplot函数的参数。

library(heplots)
?heplot
args(heplot)

function (mod, ...) 
NULL

I want to get the following part:我想得到以下部分:

## 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 is an S3 generic function. heplot是一个 S3 通用函数。 It uses a method, heplot.mlm , which is a non-exported function.它使用一种方法heplot.mlm ,这是一个非导出函数。 You can access that information by first looking at the function body of heplot .您可以通过首先查看heplot的函数体来访问该信息。 If you see UseMethod in a function body, the function uses a method.如果您在函数体中看到UseMethod ,则该函数使用了一个方法。 All the available methods for S3 generic functions can be accessed with methods S3 泛型函数的所有可用方法都可以通过methods访问

> methods(heplot)

To access a non-exported function, you can use ::: .要访问非导出函数,您可以使用::: Wrap that call with args and you have the argument list you're looking for.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

Note: This function obviously has a lot of arguments, so注意:这个函数显然有很多参数,所以

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

might be a nicer, more readable way to go through the argument list.可能是浏览参数列表的更好、更易读的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 R ZEFE90A8E604A7C840E88D03A7DZ 中为 function arguments 设置别名? - How to set aliases for function arguments in an R package? 在 R 核心包函数中重新定义参数 - Redefine arguments within an R core package function 从 merlin 中的 mlrcs function 获取预测 R 中的 package - Getting predictions from mlrcs function in merlin package in R 使用noamtools R软件包中的help_console函数获取R函数的帮助 - Getting help of R function using help_console function from noamtools R package 使用名称获取R中父函数的参数 - getting the arguments of a parent function in R, with names R包/函数-为函数参数添加黄色注释框 - R package/function - adding yellow comment boxes for function arguments R function 从 ZC1C425268E68385D1AB5074C17A94F1 继承 arguments - R function inheriting arguments from function that called it 从 [包] 导入 [功能] 在 R - From [package] import [function] in R R 将“空白”或“缺失”arguments 传递到 package ZC1C425268E18385D1AB507 与 elseC 语句 - R pass “blank” or “missing” arguments to package function with if else statement 如何在 R Shiny 中执行 function 并单击 Action? - How to execute a function in R Shiny after getting arguments from selectInput or sliderInput and clicking on ActionButton?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM