Write an R Package from Scratch with Github
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Writing an R package is simple. Writing an R package via Github is simple and smart. Github adds all the traditional benefits of version control, in addition to showing off your work and providing and facilitating publication of your package. This tutorial was inspired by a blog post from the beautiful Hillary Parker last year. I used her tut myself, but trying to integrate it with Github leads to some headaches and I felt there were a couple of other small additions to be made.
This has been sitting in my Evernote for some time, so I figured it was about time to upload to my own highly neglected blog, however as a caveate I’ll say that I still need to append more sample code and such, so watch for updates.
Step 0: Load the necessary packages
pacman::p_load("devtools", "roxygen2")
Step 1: Create your package directory
* Open a .R file to begin writing code
* Open the automatically generated README.md file and edit appropriately
Step 2: Add functions
Step 3: Add minimal documentation
* Utilize roxygen2 by typing create(“packagename”)
* Delete the folder created by roxygen2
Step 4: Add optional, but recommended example and docs
For more detail:
http://r-pkgs.had.co.nz/vignettes.html
Step 5: Process your documentation
setwd
(
"./dogs"
)
document
()
Step 6: Install your package!
setwd
(
".."
)
install
(
"dogs"
)
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.