knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file()) # Set WD to Root
here::i_am("dev/build.Rmd")
library(here)

Release PKG

Version

usethis::use_dev_version()
usethis::use_version("patch")
usethis::use_version("minor")

Github Release

usethis::use_github_release()

1. Git & Build

usethis::use_git()

Git Ignore

usethis::use_git_ignore("*.nb.html") # Ignore dev/ html_notebook
# usethis::use_git_ignore("testdata/") # ignore private Test Data in `inst/testdata`

Build Ignore

May be not ignore dev/ ?

usethis::use_build_ignore("dev")

Github Links

usethis::use_github_links()

Github Action

usethis::use_github_actions()

Test coverage workflow

  1. Call usethis::use_coverage()
# usethis::use_coverage()
  1. Set github action
use_github_action("test-coverage")

Ref

this will connect your package to codecov.

covr::codecov(token = "")
  1. Package Coverage (Local)
covr::package_coverage()

for interactive use

covr::report()

2. DOCs

DESCRIPTION

# usethis::use_description(
# fields = list(
#   Title = "R Markdown for PDF in Thai language",
#   `Authors@R` = 'person("Kittipos", "Sirivongrungson", 
#                         email = "ki11ip0.s.a.s@gmail.com", 
#                         role = c("aut", "cre"))',
#   Description = "Provide R Markdown templates and LaTeX preamble which is necessary for creating PDF in Thai language.",
#   License = "MIT + file LICENSE",
#   Depends = "R (>= 4.0.0)"
#   )
# )

LICENSE

usethis::use_mit_license()

Logo

usethis::use_logo("man/figures/logo.png")

README

usethis::use_readme_rmd()
usethis::use_lifecycle_badge("experimental")
# usethis::use_lifecycle_badge("deprecated")

NEWS

usethis::use_news_md()

vignette

usethis::use_vignette("thaipdf")

Article

usethis::use_article("quarto-pdf", "Quarto in Thai language to PDF")

Images folder

fs::dir_create(here("vignettes/articles/img"))

3. Dependencies

Import

# usethis::use_pipe()
usethis::use_package("fs")
usethis::use_package("cli")
usethis::use_package("rmarkdown")
usethis::use_package("bookdown", type = "Suggests")

Import from

# usethis::use_import_from("rlang", ":=") # Must have if use rlang

Global variables

# Put this in  R/globals.R
# utils::globalVariables(c("var1"))
# usethis::use_r("globals.R")

4. Tests

usethis::use_testthat()

Helper Functions for test -> create testthat/helper.R manually

If you want to use data for testing, put data file(s) in inst/testdata. The path to this data can be obtained by system.file("testdata",...,package="my_package").

For example, If I put cars.csv in inst/testdata, to read into R use this command read.csv(system.file("testdata","cars.csv", package="my_package")).

ref

Path to testdata folder: put this in testthat/test-helper.R:

path_testdata <- function(..., package = "pkg_name") {

  system.file("testdata", ... ,package = package)

}

5. Data

Exported Data

To store exported data in data/. Each file in this directory should be .rda file containing a single object.

To store code that used for data preparation in data-raw/

# usethis::use_data(export_df1,export_df2) 

# usethis::use_data_raw("export_df1") # Code to Prepare data
# usethis::use_data_raw("export_df2") # Code to Prepare data

How to Document a Data set

Document the name of the data in R/ as roxygen2:

#' Prices of 50,000 round cut diamonds.
#'
#' A dataset containing the prices and other attributes of almost 54,000
#' diamonds.
#'
#' @format A data frame with 53940 rows and 10 variables:
#' \describe{
#'   \item{price}{price, in US dollars}
#'   \item{carat}{weight of the diamond, in carats}
#'   ...
#' }
#' @source \url{http://www.diamondse.info/}
"diamonds"

Internal Data

Save all of the objects for internal use in R/sysdata.rda. Usually, they don’t need to be documented.

# usethis::use_data(df1, df2, df3, internal = TRUE)


Lightbridge-KS/thaipdf documentation built on June 18, 2022, 6:58 a.m.