My useful R package.
gitee 地址:https://gitee.com/mugpeng/pengToolkit
github 安装:
# install devtools
install.packages("devtools")
devtools::install_github("mugpeng/pengToolkit")
#安装官方包‘remotes’
install.packages("remotes")
#安装官方包‘git2r’
install.packages("git2r")
remotes::install_git("https://gitee.com/mugpeng/pengToolkit.git")
下载打包后本地安装:
install.packages("/dir2file/pengToolkit-main", repos = NULL, type = "source")
一共五个函数:
pengToolkit::
pengToolkit::boost_install_packages pengToolkit::set_mirror
pengToolkit::make_r_template
##################################################
## Project:
## File name: test2.R
## Date: Wed May 19 18:24:26 2021
## Author: Peng
## R_Version: R version 4.0.5 (2021-03-31)
##################################################
pengToolkit::boost_install_packages(c("ggplot2", "devtools"))
[1] "ggplot2 is already installed."
[1] "devtools is already installed."
[1] "ggplot2 devtools are already in your computer."
现在还支持多线程、后台、开启镜像下载。
set_mirror() # 参数"China" 可有可无
set_mirror("reset") # 当你无需镜像之时,可以恢复默认设置
可以直接添加函数到 ./my_function.R(需要将函数名改为字符串形式) 脚本内,解决主脚本因为函数定义而显得臃肿。
比如添加事先定义好的两个函数:
> add_function("test001", "test002")
Now you can find your functions in : ./my_function.R
再打开 ./my_function.R:
test001 <-function(x) {
x + 1
}
test002 <-function(x) {
x + 1
}
目前我整理了一些安装包出现的报错,记录在:
https://www.yuque.com/mugpeng/rr/cvaadg
如果有任何使用的问题,也欢迎大家在issue 中提出。
初始版。
发布版。
set_mirror 函数添加恢复方法:
set_mirror("reset") # 当你无需镜像之时,可以恢复默认设置
对帮助文档进行了修改。 添加了依赖包设置。 添加了单元测试设置。
灵感来源于pacman::p_load(),如果可以安装包时增加选项,loaded, 如果为T,则判断式安装完包后,会加载它们。
> boost_install_packages(c("ggplot2","ggsci"), loaded = T)
[1] "ggplot2 is already installed."
[1] "ggsci is already installed."
[1] "ggplot2, ggsci are already in your computer."
[1] "ggplot2, ggsci are also successfully loaded in your namespace."
Warning message:
package ‘ggsci’ was built under R version 4.0.5
> update_myself()
upgrading this package from github mugpeng/pengToolkit
Downloading GitHub repo mugpeng/pengToolkit@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
> boost_install_packages("viridis", mirror = T, parallels = 2, jobs = T)
Now you successfully take a mirror, go ahead without any restrictions!
Now will use jobs for installing. HAPPY! console is free now!
Job launched.
We will use 2 cores for installing.
You can set ur parallels back by: options(Ncpus = 1)
You can set ur mirror back by: set_mirror('reset')
jobs 选项调用job 包,可以直接调用后台安装。 ps:关于R 包的更新,墙裂推荐大噶使用Y 叔叔的rvcheck,好用极了~
> boost_install_packages("paletteer", parallels = 100)
paletteer is already installed.
paletteer are already in your computer.
You think too high to your cpu, I will set it to a safe number.
We will use 3 cores for installing.
比如添加事先定义好的两个函数:
> add_function("test001", "test002")
Now you can find your functions in : ./my_function.R
再打开 ./my_function.R:
test001 <-function(x) {
x + 1
}
test002 <-function(x) {
x + 1
}
更新update_myself,解决因为环境中加载pengToolkit 而无法更新报错。
新增函数p_select,专门用于处理向量,reverse 参数取反。
修改函数make_r_template : 创建文件后会直接打开。
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.