

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check the least number of arguments a function expects in R?
To find the least number of arguments a function expects while using in R can be done with the help of the syntax: length(formals(“function_name”)). For example, to find the number of arguments expected by mutate function of dplyr package can be calculated by using the command length(formals(mutate)) but we need to make sure that the package is loaded.
Examples
library(ggplot2) length(formals(ggplot))
Output
[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
- Related Questions & Answers
- How can I find the number of arguments of a Python function?
- Passing unknown number of arguments to a function in Javascript
- How to use variable number of arguments to function in JavaScript?
- How to use unlimited arguments in a JavaScript function?
- How number values be used as arguments in MySQL STRCMP() function?
- How to pass arguments by reference in a Python function?
- How to check if a string has at least one letter and one number in Python?
- PHP Function arguments
- Variable number of arguments in C++
- How to change all the function arguments to lowercase in Python?
- What are required arguments of a function in python?
- How to use variable-length arguments in a function in Python?
- Function to calculate the least common multiple of two numbers in JavaScript
- Variable number of arguments in Lua Programming
- Tkinter binding a function with arguments to a widget
Advertisements