Idle thoughts lead to R internals: how to count function arguments
“Some R functions have an awful lot of arguments”, you think to yourself. “I wonder which has the most?”
It’s not an original thought: the same question as applied to the R base package is an exercise in the Functions chapter of the excellent Advanced R. Much of the information in this post came from there.
There are lots of R packages. We’ll limit ourselves to those packages which ship with R, and which load on startup. Which ones are they?
What packages load on starting R?
Start a new R session and type search(). Here’s the result on my machine:
search()
[1] ".GlobalEnv" "tools:rstudio" "package:stats" "package:graphics" "package:grDevices"
"package:utils" "package:datasets" "package:methods" "Autoloads" "package:base"
We’re interested in the packages with priority = base. Next question:
How can I see and filter for package priority?
You don’t need dplyr for this, but it helps.
library(tidyverse)
installed.packages() %>%
as.tibble() %>%
filter(Priority == "base") %>%
select(Package, Priority)
# A tibble: 14 x 2
Package Priority
<chr> <chr>
1 base base
2 compiler base
3 datasets base
4 graphics base
5 grDevices base
6 grid base
7 methods base
8 parallel base
9 splines base
10 stats base
11 stats4 base
12 tcltk base
13 tools base
14 utils base
Comparing to the output from search...
Source: What You're Doing Is Rather Desperate - Category: Bioinformatics Authors: nsaunders Tags: R statistics Source Type: blogs
More News: Bioinformatics | Databases & Libraries | PET Scan | Sports Medicine | Statistics | Warnings