-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevtools.rmd
156 lines (125 loc) · 4.35 KB
/
devtools.rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Develop R package
## Now
```{r check}
## check
devtools::build_vignettes()
devtools::document(roclets = c("rd", "collate", "namespace"))
devtools::check() # 快捷键:Ctrl + Shift + E
## check for cran
# library(rhub)
# rhub::validate_email(email = "yanpd01@gmail.com", token = "6f28055d6e6e42ba80edae8641e6d9dc")
rhub::rhub_setup()
# git add .
# git commit -m 'workflow 2'
# git push origin main
rhub::rhub_doctor()
rhub::rhub_check()
## install
devtools::install_local()
remotes::install_github("yanpd01/ggsector", build_vignettes = TRUE)
remotes::install_git("https://gitee.com/yanpd01/ggsector", build_vignettes = TRUE)
## load
devtools::load_all() # 快捷键:Ctrl + Shift + L
devtools::unload()
## build
# devtools::build_readme()
devtools::build()
remotes::install_github("yanpd01/ggsector", build_vignettes = TRUE)
system("code .gitignore")
```
```{bash git}
## git common -----------------------------------------------------
git add .
git commit -m "cran fix" # 将文件提交到本地仓库
git push
git push -u origin main ## push the develop repos
git tag V0.0.5.1
git push origin V0.0.5.1
git commit --amend ## 修改注释
## init -----------------------------------------------------------
git config --global user.name "Yan"
git config --global user.email "yanpd01@gmail.com"
git config --global core.autocrlf false
git config --global core.saftcrlf true
git init
git add .
git commit -m "creat pkg"
git branch -M main
git remote add origin https://github.com/yanpd01/ggsector.git
git remote set-url --add origin https://gitee.com/yanpd01/ggsector.git
git push -u -f origin main
## branch --------------------------------------------------------
git checkout develop ## switch to develop branch
git checkout master ## switch to master branch
git merge --no-ff develop ## merge develop to master
git branch -d develop ## delete local branch
git push origin --delete develop ## delete remote branch
## tag -----------------------------------------------------------
# git tag -a v1.2 9fceb02 -m "my tag" ## add tag for sepcific commit.
git tag V0.0.5.0 ## add git tag.
git push origin --tags ## push all tags to remote.
git push origin v1.0 ## push specific tag to remote.
git tag -d V0.0.5.0 # delete local tag
git push origin :refs/tags/V0.0.5.0 # delete remote tag
##
git reset --soft HEAD^ ## 撤销上次提交
git reset --soft HEAD~1 ## 撤销上次提交
git reset --soft HEAD~2 ## 撤销上两次提交
```
```{bash install}
cd ..
"C:\Program Files\R\R-4.2.2\bin\x64\Rcmd.exe" INSTALL \
--no-multiarch \
--with-keep.source \
--library="C:/Users/yan/AppData/Local/R/win-library/4.2" \
ggsector
```
```{r install}
remotes::install_github("yanpd01/yyeasy", upgrade = "never")
```
## build R package flow
```{r flow}
## 0、prepare
devtools::has_devel()
## 1、create pkg project -------------------------------------------------------
usethis::create_package("ggsector")
## 2、open the pkg dir, add detail
# Add、Title、Authors、Description、License
'
Title: Draw sector in R
Version: 0.5.0
Authors@R:
person(given = "Pengdong",
family = "Yan",
role = c("aut", "cre"),
email = "yanpd01@gmail.com",
comment = c(ORCID = "0000-0002-2425-7930"))
Description: `ggsector` is an R package that can use `grid` or `ggplot` to easily draw sectors.
License: Artistic-2.0
'
# library
library(devtools)
library(roxygen2)
library(usethis)
# add document
use_readme_rmd()
use_vignette("ggsector")
# add R file
use_r("reexport") ## 导入和导出
use_r("function") ## 编写功能
# add data
use_data(its) ## 先将本地数据导入 R 中变量,然后用这个函数将数据导入到包中
use_r("data") ## 为数据编写R文件
# add depends
use_package("magrittr")
## 3、annotation --------------------------------------------------------------
yourname <- function() {
## 这个位置按下 Ctrl+Alt+Shift+R 插入注释框架
}
devtools::document() ## 转义注释
## 4、load check and build -----------------------------------------------------
devtools::load_all() ## 快捷键:Ctrl + Shift + L 相当于library,可以测试当前包
devtools::unload() ## 前面加载的卸载
devtools::check() ## 快捷键 Ctrl + Shift + E
devtools::build() ## 快捷键 Ctrl + Shift + B
```