Nepalwildlife package brings together a list of wild animals and plants
found in Nepal. It contains 1 tibble named nepal_wildlife
.
You can install the released version of Nepalwildlife from Github with:
install.packages("devtools")
devtools::install("abhinabkadel/Nepalwildlife")
How many species fall under different taxonomic groups in Nepal? Let’s solve it using the dataset:
library(Nepalwildlife)
library(tidyverse)
nepal_wildlife %>%
count (`Taxonomic Group`)
#> # A tibble: 8 x 2
#> `Taxonomic Group` n
#> <chr> <int>
#> 1 Amphibians 58
#> 2 Birds 852
#> 3 Butterflies 26
#> 4 Conifers 23
#> 5 Mammals 217
#> 6 Reptiles 44
#> 7 Sphingid moths 174
#> 8 Turtles (non-marine) 15
- Load devtools using
library(devtools)
- Use
create_package(pathname/Nepalwildlife)
. This created a folder named Nepalwildlife with skeleton for the package contents such as DESCRIPTION and an R project file. - In the new Rstudio session that is opened, load usethis package
using
library(usethis)
- Set up git repo using use_git(). Perform initial commit and restart RStudio to activate the Git pane.
- Create a directory for raw data using
use_data_raw()
- Add the dataset downloaded from the Map of Life in .csv form into the newly created data-raw folder.
- Add a R script titled
nepal_wildlife.R
in the folder, which converts the csv to a tibble in the .R file.- Include
usethis::use_data()
at the bottom of this R script to create a .rda data object in the data folder
- Include
- Check to data folder in the root directory to see if nepal_wildlife.rda object exists.
- Create a new R script called nepal_wildlife.R in the R folder in the root directory.
- Create roxygen style documentation in it, ending with the line
"nepal_wildlife"
- There is not need to use
@export
tag because I am not creating any function and it was advised in class not to do so.
- There is not need to use
- Run
document()
use_testthat()
to create a tests folder in the root directoryuse_test("nepal_wildlife")
creates an R file with my tests in it.- Write test codes using
expect_
statements to check if:- the variable names of the dataset are as expected.
- dataset is stored as a tibble
- the the dataset has expected number of observations.
- Check if tests pass using
test()
- Open DESCRIPTION file in a code editor
- Edit the Title, Authors and Description fields as necessary.
- Add license info using
usethis::use_mit_license("Abhinab Kadel")
- Add dependencies using
use_package()
. The following packages are listed under the @import option:- Package tests specified above use dplyr and tibble packages.
- Vignette uses stringr and ggplot2
- Create readme using
use_readme_rmd( )
and build it usingbuild_readme( )
. - Create vignette using
use_vignette("nepal_wildlife")
and build it usingbuild_vignette()
.
Use devtools::install()
- Create a remote repository on Github called
Nepalwildlife
- Push package contents from local repo to remote repo using the instructions provided in Github.
- Run
usethis::use_code_of_conduct()
to create a code of conduct text. Then, paste it to the README file (see below) - Create a NEWS.md file using
use_news_md()
- Run
usethis::use_version()
and select minor increment to set the package version to 0.1.0- This adds a new heading in the NEWS.md file with the package name and version nr.
- Update information to the NEWS.md file.
- Build the website:
- Activate pkgdown using
usethis::use_pkgdown()
- Build website using
pkgdown::build_site()
- Push the contents of root/docs folder to the remote repository
- Activate Github Pages through repository settings and select master/docs as website source.
- Website can be found here
- Activate pkgdown using
Please note that the Nepalwildlife project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.