-
Notifications
You must be signed in to change notification settings - Fork 10
/
extra_replace.R
executable file
·54 lines (44 loc) · 1.61 KB
/
extra_replace.R
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
# after pkgdown, let's set all the families
rm(list=ls())
library(xfun)
library(rstudioapi)
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
# step 1. list all files in R directory
Rfiles = list.files("R")
Rpaths = paste0(getwd(),"/",Rfiles)
# step 2. do "linear_" filenames
Rlinear = paste0(getwd(),"/R/",list.files("R",pattern="^linear_"))
for (i in 1:length(Rlinear)){
val = grep("rdname linear_",readLines(Rlinear[i]))
if (length(val)>0){
gsub_file(file=Rlinear[i],"@export", "@family linear_methods \n#' @export")
}
}
# step 3. do "nonlinear_" functions
Rfiles = paste0(getwd(),"/R/",list.files("R",pattern="^nonlinear_"))
for (i in 1:length(Rfiles)){
val = grep("rdname nonlinear_",readLines(Rfiles[i]))
if (length(val)>0){
gsub_file(file=Rfiles[i],"@export", "@family nonlinear_methods \n#' @export")
}
}
# Correction --------------------------------------------------------------
# If @family is used, all the functions are cross-referenced.
# In order to avoid this, use @concept rather for better grouping.
# It's not automatically added but still way better.
Rfiles = paste0(getwd(),"/R/",list.files("R"))
for (i in 1:length(Rfiles)){
val = grep("@family",readLines(Rfiles[i]))
if (length(val)>0){
xfun::gsub_file(file=Rfiles[i],"@family", "@concept")
}
}
# Correction 2. figure ----------------------------------------------------
# mfrow=c(3,1) -> mfrow=c(1,3)
Rfiles = paste0(getwd(),"/R/",list.files("R"))
for (i in 1:length(Rfiles)){
val = grep("mfrow=c(3,1)",readLines(Rfiles[i]))
if (length(val)>0){
xfun::gsub_file(file=Rfiles[i],"mfrow=c(3,1)", "mfrow=c(1,3)")
}
}