Creating R project with Unit tests and documentation.
https://github.com/AlexKorole/myRTestPrj
1-3 help: https://datag.org/resources/documents...
1. Install R
https://www.r-project.org/ -- https://cloud.r-project.org/
2. Install RStudio
https://www.rstudio.com/
3. Install Rtools
https://cran.r-project.org/bin/window...
----------------------------------------------------------------------
4. Create new project
File -- New Project -- New Directory -- R Package
myRTestPrj
5.
install.packages("devtools")
6.
hello стрелка влево- function(a) {
print(paste0("Hello, ", a, ", this is the world!"))
}
Code -стрелка вправо Insert Roxygen Sceleton
#' Title
#'
#' @param a input name
#'
#' @return phrase
#' @export
#'
#' @examples
#' hello("John")
7.
delete NAMESPACE and hello.Rd
8.
install.packages("xfun")
devtools::document()
?hello
9.
usethis::use_mit_license()
10.
usethis::use_testthat()
11.
usethis::use_test("hello")
test_that("multiplication works", {
expect_equal(hello("J"), "Hello, J, this is the world!")
})
12.
devtools::test()
13.
install.packages("covr")
covr::report()
14.
devtools::check()
15.
hello("df")
16.
usethis::use_readme_rmd()
17.
devtools::build_readme()
18.
install.packages("forcats")
usethis::use_package("forcats")
in hello.R
forcats::
19.
devtools::install()
20.
remove.packages("myRTestPrj")
21.
restart Session
22.
hello("df")
devtools::load_all()
hello("df")