regex - Is there a way to get a list with of all functions which names match a given regular expressions? -


i list of functions name match given pattern. instance, have functions name includes "theme_".

i've seen this post gives solution vector of names. possible have same list of functions instead of vector of names ?

for local packages might try this:

if (!require("pacman")) install.packages("pacman"); library(pacman)  regex <- "theme_" packs <- p_lib()  out <- setnames(lapply(packs, function(x){     funs <- try(p_funs(x, character.only=true))     if (inherits(funs, "try-error")) return(character(0))     funs[grepl(regex, funs)] }), packs)  out[!sapply(out, identical, character(0))] 

here's output:

## $cowplot ## [1] "theme_cowplot" "theme_nothing" ##  ## $ggplot2 ##  [1] "theme_blank"    "theme_bw"       "theme_classic"  "theme_get"      "theme_gray"     "theme_grey"     "theme_light"    "theme_line"     "theme_linedraw" "theme_minimal"  ## [11] "theme_rect"     "theme_segment"  "theme_set"      "theme_text"     "theme_update"   ##  ## $gridextra ## [1] "ttheme_default" "ttheme_minimal" ##  ## $plotflow ## [1] "theme_apa"   "theme_basic" "theme_black" "theme_map"   ##  ## $qdap ## [1] "theme_badkitchen" "theme_cafe"       "theme_duskheat"   "theme_grayscale"  "theme_greyscale"  "theme_hipster"    "theme_nightheat"  "theme_norah"      

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -