Read "Writing R Extensions" for more information.
Read R Packages for details.
load all
use devtools::load_all()
in R console.
check()
use devtools::check()
in R console.
Edit man
floder (if modification is needed)
r
or cpp
file correctly.See slides AR3_.pdf page 4.
devtools::document()
This will create documents in
man
.Rd files and create NAMESPACE file.Before use
document()
, you should delete NAMESPACE.
Edit vignettes
floder (if modification is needed)
See above.
# install from remote
devtools::install_github("DawnGnius/SC19086", ref = "master", dependencies = TRUE, upgrade = "ask", build_vignettes = TRUE)
devtools::install_github("DawnGnius/SC19086", build_vignettes=TRUE)
# using `build_vignettes`, we can force installing package with vignettes.
# install from local
devtools::install(".", build_vignettes=TRUE)
# using `build_vignettes`, we can force installing package with vignettes.
# load this package
library(SC19086)
# remove from your lib
remove.packages("SC19086", lib="~/R/win-library/3.6")
This is a vignette rmarkdown file.
Reference: https://r-pkgs.org/vignettes.html
usethis::use_vignette("my-vignette")
This will:
Create a vignettes/ directory.
Add the necessary dependencies to DESCRIPTION (i.e. it adds knitr to the Suggests
and VignetteBuilder
fields).
Draft a vignette, vignettes/my-vignette.Rmd
.
There are 2 methods:
devtools::build_vignettes()
Build all vignettes from the console.
devtools::build()
Create a package bundle with the vignettes included.
Note that
#> devtools::build()
#>Building the package will delete...
#> 'C:/Users/Gnius/Documents/Code/R/SC-R/inst/doc'
#>Are you sure?
Note that
RStudio’s Build & reload
does not build vignettes to save time.
Similarly, devtools::install_github()
(and friends) will not build vignettes by default because they’re time consuming and may require additional packages.
You can force building with devtools::install_github(build_vignettes = TRUE)
.
This will also install all suggested packages.
cpp function cannot be called, after installing from local.
add
@useDynLib SC19086, .registration = TRUE
into cpp files befor@export
lineadd
@importFrom Rcpp evalCpp
into any one cpp fileadd
@exportPattern "^[[:alpha:]]+"
into any one cpp fileadd
Encoding: UTF-8
into DESCRIPTION
devtools::document()
will auto create/update .Rd files inman
floder and alsoNAMESPACE
Please, Check
Rcpp::Rcpp.package.skeleton()
for detials.
Rename your R package and your R project
This is a strange request, but we may occure it. We should change all filename firstly.
Then we need to focuce on file contents
1. DESCRIPTION
2. src
, R
, man
floder are important. Something we can change by hand, something cannot.
3. Notice: @useDynLib SC19086, .registration = TRUE
, please change NAMESPACE
by hand before devtools::document()
4. Use findstr /s /i "StatComp19086.DLL" *.*
to deal with the most difficult thing. And then, everything works well.
Cannot find function after installing.
Check NAMESPACE
export function. If not exist, document() again.
Cannot install my package in other computers.
Add dependencies into DESCRIPTION
, it's not auto.
Cannot instal my package in other computers [build vignettes error]
Add dependencies into Imports
rather than Suggests
in DESCRIPTION
file.
dependencies auto install pkgs in "Depends", "Imports", "LinkingTo"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.