Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/karim-mane/test

steps to follow for creation of R package
https://github.com/karim-mane/test

Last synced: about 2 months ago
JSON representation

steps to follow for creation of R package

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
suppressPackageStartupMessages(require("devtools"))
suppressPackageStartupMessages(require("usethis"))
suppressPackageStartupMessages(require("pkgdown"))
suppressPackageStartupMessages(require("covr"))
```

# test

[![Codecov test coverage](https://codecov.io/gh/Karim-Mane/test/branch/master/graph/badge.svg)](https://app.codecov.io/gh/Karim-Mane/test?branch=master)

The goal of test is to provide functions that are useful for the creation of an R package.

## Installation

You can install the development version of test from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("Karim-Mane/test")
```

## Loading the package after installation

```{r example}
library(test)
```

## Create an R project and link it with a remote GitHub account
The **createPackage()** function is used to create an R project and link it to a remote GitHub account and perform the first commit to that account. The function requires the following parameters:
1. `package.name`: the name of the package/project to be created
2. `where`: the path to the directory where package will be created
3. `organisation.name`: the name of the organisation in which the package will be created. For **Epiverse TRACE**, this will be `epiverse-trace`. For Karim's github account, this will be `Karim-Mane`
```{r eval=FALSE}
createPackage(package.name="test",
where="/Users/km28/Documents/Karim/Karim/LSHTM/Codes",
organisation.name="Karim-Mane")
```

## Set up the package components
Use the **setUpPackageComponents()** to set up the package components i.e. to:
* set up a licence,
* create a Readme file,
* set up unit testing infrastructure,
* set up a pkgdown website,
```{r eval=FALSE}
setUpPackageComponents()
```

## Build and update the Readme.md from the README.Rmd
To build the Readme.md file from the README.Rmd file, use the **updateReadMe()**. This function needs to be called after any modification of the README.Rmd file.
```{r eval=FALSE}
updateReadMe()
```

## Build the package website
The package website can be built using the **pkgdown** package in R. After editing all your functions and documentation files, use the **buildPkgdownWebsite()** function to build the website.
```{r eval=FALSE}
buildPkgdownWebsite()
```

## Add list of package dependencies
Once identified, the list of packages on which the current package depends on can will be added to the **DESCRIPTION** file using the **addPkgDepencies()** function. The function expects the following parameters:
1. `dependencies`: a vector of packages on which the package to be built depends on
```{r eval=FALSE}
addPkgDepencies(dependencies=c("devtools","usethis","pkgdown","covr"))
```

## Build the package documentation
When you are satisfied with the documentation of all the functions, use the **buildPkgDocumentation()** to build the documentation files in the `man/` folder and update the **NAMESPACE** file.
```{r eval=FALSE}
buildPkgDocumentation()
```

## Commit and push the changes to the remote GitHub account
For any changes/updates made on any of the files of the package use the command below to update the remote GitHub account.
```{bash eval=FALSE}
git add .
git commit -a -m "updates"
git push origin master
```