forked from mayer79/flashlight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packaging.R
104 lines (83 loc) · 3.44 KB
/
packaging.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
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
#=====================================================================================
# BUILD THE PACKAGE
#=====================================================================================
if (FALSE) {
library(MetricsWeighted)
library(dplyr)
library(tidyr)
library(rlang)
library(ggplot2)
library(ggpubr)
lapply(list.files("R", full.names = TRUE), source)
}
library(usethis)
library(devtools)
# Create a new package
dir.create(file.path("release"))
pkg <- file.path("release", "flashlight")
create_package(
pkg,
fields = list(
Title = "Shed Light on Black Box Machine Learning Models",
Type = "Package",
Version = "0.6.0",
Date = Sys.Date(),
Description = "Shed light on black box machine learning models by the help of model performance, variable importance, ICE profiles, partial dependence (Friedman J. H. (2001) <doi:10.1214/aos/1013203451>), accumulated local effects (Apley D. W. (2016) <arXiv:1612.08468>), further effects plots, scatter plots, interaction strength, and variable contribution breakdown (approximate SHAP) for single observations (Gosiewska and Biecek (2019) <arxiv:1903.11420>). All tools are implemented to work with case weights and allow for stratified analysis. Furthermore, multiple flashlights can be combined and analyzed together.",
`Authors@R` = "person('Michael', 'Mayer', email = '[email protected]', role = c('aut', 'cre', 'cph'))",
URL = "https://github.com/mayer79/flashlight",
BugReports = "https://github.com/mayer79/flashlight/issues",
Depends = "R (>= 3.5.0)",
VignetteBuilder = "knitr",
License = "GPL(>= 2)",
Maintainer = "Michael Mayer <[email protected]>"))
file.copy(file.path(pkg, "DESCRIPTION"), to = getwd(), overwrite = TRUE)
# Use package has no option to look for pkg, so we first copy description from pkg, modify it and move back
# Imports
use_package("stats", "Imports")
use_package("utils", "Imports")
use_package("dplyr", "Imports")
use_package("tidyr", "Imports")
use_package("rlang", "Imports")
use_package("ggplot2", "Imports")
use_package("ggpubr", "Imports")
use_package("MetricsWeighted", "Imports", min_version = "0.3.0")
# Suggests
use_package("knitr", "Suggests")
use_package("lubridate", "Suggests")
use_package("ranger", "Suggests")
use_package("xgboost", "Suggests")
use_package("caret", "Suggests")
use_package("moderndive", "Suggests")
# Set up other files -------------------------------------------------
# use_readme_md()
# use_news_md()
# use_cran_comments()
# Copy readme etc.
file.copy(c(".Rbuildignore", "NEWS.md", "README.md", "cran-comments.md", "DESCRIPTION"),
pkg, overwrite = TRUE)
# Copy R scripts and document them
files <- list.files("R", full.names = TRUE)
file.copy(files, file.path(pkg, "R"), overwrite = TRUE)
devtools::document(pkg)
# Copy vignette
dir.create(file.path(pkg, "vignettes"))
dir.create(file.path(pkg, "doc"))
dir.create(file.path(pkg, "Meta"))
file.copy(list.files("vignettes", full.names = TRUE), file.path(pkg, "vignettes"), overwrite = TRUE)
devtools::build_vignettes(pkg)
# Check
check(pkg, manual = TRUE)
# Create
build(pkg)
build(pkg, binary = TRUE)
# Install
install(pkg)
# Load
library(flashlight)
# modify .Rbuildignore in build project to ignore the proj file.
check_win_devel(pkg)
check_rhub(pkg)
# setwd(pkg)
devtools::release(pkg)
usethis::use_pkgdown()
pkgdown::build_site(pkg)