-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_package.R
35 lines (27 loc) · 1.36 KB
/
create_package.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
# remove old version first
remove.packages('nmmsims')
# create R functions from C++ files
Rcpp::compileAttributes()
# nmmsims_package_exists <- ("nmmsims" %in% installed.packages()[,"Package"])
# Say that the package uses UTF-8 for stuff
# write('Encoding: UTF-8', file='DESCRIPTION', append=TRUE)
# create documentation
devtools::document()
# build the library
devtools::build(path = 'G:/My Drive/Sharing')
# install the package
devtools::install(dependencies=TRUE)
# load the library into session
library('nmmsims')
# nmmsims::
# download.file(url = 'https://cdn-33.anonfile.com/zaOeO4Dfn8/8cbe1a96-1575689524/nmmsims_1.0.tar.gz', destfile = 'nmmsims_1.0.tar.gz')
# install.packages('nmmsims_1.0.tar.gz', repos = NULL, type="source")
# install.packages('https://cdn-33.anonfile.com/zaOeO4Dfn8/8cbe1a96-1575689524/nmmsims_1.0.tar.gz', repos = NULL, type="source")
# there are many more potential improvements here, see: http://r-pkgs.had.co.nz/src.html
# Whenever you use C++ code in your package, you need to clean up after yourself when your package is unloaded.
# Do this by writing a .onUnload() function that unloads the DLL:
.onUnload <- function (libpath) {
library.dynam.unload("nmmsims", libpath)
}
# but... https://stackoverflow.com/questions/26691878/must-r-packages-unload-dynamic-libraries-when-they-unload
# devtools::install_github(repo = 'philipshirk/nmmsims')