Suppose I have base , dplyr , data.table , tidyr , etc. packages downloaded using sapply() .
sapply(c("dplyr","data.table","tidyr"),library,character.only=TRUE)
So, to check the list of functions in a specific package, I do
ls("package:data.table")
Now, if I want to look for functions inside dplyr , starting with the is. template is. i do
grep("is\\.",ls("package:dplyr"),value=TRUE) # [1] "is.grouped_df" "is.ident" "is.sql" "is.src" # [5] "is.tbl"
My goal is to search for all functions starting with is. or as. , or any other template in several packages at the same time. A code that I think would be long, i.e. Below. I combined the list of dplyr and base functions and then added the grep template. How to do this for many downloaded packages?
grep("is\\.",c(ls("package:dplyr"),ls("package:base")),value=T)
The search() function will provide me with a list of downloaded packages. But how to collect all the functions of the downloaded packages so that I can grep later on it.
For one package, a list of functions can be obtained using
ls("package:package_name")
Any help is appreciated.
regex grep r pattern-matching perl
Sowmya S. Manian
source share