想看一个R函数的源文件 想到github上去找 但是我们不知道在哪个文件里 于是找啊 找啊 找啊 真的很难找哎 为了解决这个问题,我写了pkgexp包 devtools::install_github("yikeshu0611/pkgexp") 在pkgexp包中,有1个函数,叫find_R(),专门用来实现查找的功能。比如我们想看ggplot2包在哪里定义了+.gg。library(pkgexp) find_R(repo = 'tidyverse/ggplot2',query = '\\+\\.gg') 首先,会在当前的工作目录下查找是否存在/tidyverse/ggplot2目录,如果没有,那么就会创建。接下来,会将ggplot2的R文件下的所有R代码下载下来,并保存在/tidyverse/ggplot2中,保存为网页格式,方便后面打开。如果工作目录不变,只下载1次。 library(pkgexp) find_R(query = '\\+\\.gg', local = 'F:/RStudio dir/tidyverse/ggplot2') ## [1] "plot-construction.r.html" "theme-current.html" ## [3] "theme.r.html" 如果我们已经把这些网页数据下载下来了,那么可以直接把地址赋值给local 参数即可。 如果我们想查找多个参数,那么直接赋值给query即可。
逻辑关系赋值给logical 参数,可以赋值的是all(默认)或者any。 library(pkgexp) find_R(query = c('\\+\\.gg','k'), logical = 'all', local = 'F:/RStudio dir/tidyverse/ggplot2') ## [1] "plot-construction.r.html" "theme-current.html" ## [3] "theme.r.html" 这个一个非常实用的功能。您肯定在以后的R实践中,感受pkgexp包的妙用!哈哈,收藏备用吧!
|