knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of Assignment2 is to learn wrapping functions inside an R package. The package contains a subsidy function that calculates the amount of subsidy received in the form of reimbursement, based on base value and subsidy percentage.
subsidy received = x*(1-%)
You can install the released version of Assignment2 from CRAN with:
devtools::install_github("berudri/Assignment2)
For this assignment, I followed the following steps:
Created a new package via devtools using create_package(), and then created a local git repository with the help of use_git().
Use load_all() to load teh functions to be used as shown in the examples.
This is a basic example which shows you how to solve a common problem:
library(Assignment2) subsidy(1300,40)
You can also use the other two functions that specify the amount of subsidy"
fifty(2450) eighty(2450)
Save each function as a seperate R folder using use_r() and run check().
Next, it is important to add required documentation for each function. This is done biw library(roxygen2). After adding in the documentation, it can be rendered thriugh document().
Testing the function: through use_testthat() and use_test()
6. Finally, I created the README file using use_readme_rmd and knitted it using build_readme().
You'll still need to render README.Rmd
regularly, to keep README.md
up-to-date.
Don't forget to commit and push the resulting figure files, so they display on GitHub!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.