Wednesday, 22 August 2018

Steps to turn a function into a package...

1. Downloaded Sefa Github repo.
2. Opened R Studio and made package - called tweetParsR

Here is a screen shot of the file structure:

3. Let's look at the function first.

Remove the library(tidyverse) at top.
Add some documentation using Roxygen tags

Here is some recommended stuff..
### parse_function
#' Turn JSON file of tweets into a CSV file
#'
#' \code{parse_function} uses the dataframe containing the protein features to
#' creates the basic plot element by determining the length of the longest
#' protein.
#'
#' @param x describe the input
#'
#' @return describe the output.
#'
#' @examples
#'
#' @import dlpyr, stringr
#'
#' @export


4. Add some double colon stuff
e.g. dplyr::filter

5. Need to design some tests...

6. DESCRIPTION edited to add some imports...


Sources:
http://tinyheero.github.io/jekyll/update/2015/07/26/making-your-first-R-package.html
https://itsalocke.com/blog/the-making-of-datasaurus/
http://r-pkgs.had.co.nz/
https://ropensci.github.io/dev_guide/building.html#building

http://happygitwithr.com/rstudio-git-github.html
https://github.com/lockedata/pRojects/blob/master/R/createPackageProject.R


No comments:

Post a Comment