如何检查函数在R中期望的最少参数个数?
要找到函数在R中使用时期望的最少数量的参数,可以借助以下语法来完成:length(formals(“function_name”))。例如,要查找dplyr软件包的mutate函数期望的参数数量,可以使用命令length(formals(mutate))计算出来,但是我们需要确保已加载该软件包。
例子
library(ggplot2) length(formals(ggplot))输出结果
[1] 4 length(formals(boxplot)) [1] 2 length(formals(qnorm)) [1] 5 length(formals(rnorm)) [1] 3 length(formals(rpois)) [1] 2 length(formals(runif)) [1] 3 length(formals(punif)) [1] 5 length(formals(plot)) [1] 3 length(formals(pbinom)) [1] 5 length(formals(qbinom)) [1] 5 length(formals(hist)) [1] 2 length(formals(data)) [1] 7 length(formals(matrix)) [1] 5 length(formals(list)) [1] 0 length(formals(data.frame)) [1] 6 length(formals(paste)) [1] 4 length(formals(gsub)) [1] 7 length(formals(factor)) [1] 6 length(formals(cut)) [1] 2 length(formals(t.test)) [1] 2 length(formals(lm)) [1] 14 length(formals(glm)) [1] 18 length(formals(prop.test)) [1] 6 length(formals(pairwise.t.test)) [1] 7 length(formals(aov)) [1] 6 length(formals(dunif)) [1] 4 length(formals(dpois)) [1] 3 length(formals(dnorm)) [1] 4 length(formals(cbind)) [1] 2 length(formals(rbind)) [1] 2 length(formals(cor)) [1] 4 length(formals(cor.test)) [1] 2 length(formals(mean)) [1] 2 length(formals(sum)) [1] 0 length(formals(median)) [1] 3 length(formals(quantile)) [1] 2 length(formals(rank)) [1] 3 length(formals(var)) [1] 4 length(formals(sd)) [1] 2 length(formals(round)) [1] 0
热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西