Reputation: 52208
A list of all R packages on CRAN can be found here.
Is there a quick and easy way to get all the function names within all of those packages?
Upvotes: 2
Views: 310
Reputation: 52208
library(collidr)
# This data.frame is ~300k rows, here are the first 10
collidr::CRANdf[1:10, ]
# package_names function_names
# 1 A3 A3-package
# 2 A3 a3
# 3 A3 a3.base
# 4 A3 a3.gen.default
# 5 A3 a3.lm
# 6 A3 a3.r2
# 7 A3 housing
# 8 A3 multifunctionality
# 9 A3 plot.A3
# 10 A3 plotPredictions
...
Upvotes: 1
Reputation: 388797
You can use lsf.str
function to get all the functions in a package
lsf.str("package:lubridate")
#%--% : function (start, end)
#%m-% : Formal class 'standardGeneric' [package "methods"] with 8 slots
#%m+% : Formal class 'standardGeneric' [package "methods"] with 8 slots
#%within% : Formal class 'standardGeneric' [package "methods"] with 8 slots
#add_with_rollback : function (e1, e2, roll_to_first = FALSE, preserve_hms = TRUE)
#....
Moreover, you can get all the packages using available.packages
function.
df <- available.packages()
This returns a matrix which has a column name "Package" which you can use programmatically to get all the function names.
sapply(df[, 1], function(x) lsf.str(paste0("package:", x)))
but this I think would require you to have all the packages downloaded on your system. It works at least for
sapply(c("lubridate", "dplyr"), function(x) lsf.str(paste0("package:", x)))
Upvotes: 1