Skip to content

Instantly share code, notes, and snippets.

@seandavi
Last active July 3, 2019 22:50
Show Gist options
  • Save seandavi/1d4e82a9d4bdd79d4e22ec37d898052c to your computer and use it in GitHub Desktop.
Save seandavi/1d4e82a9d4bdd79d4e22ec37d898052c to your computer and use it in GitHub Desktop.

Build an R package

├── DESCRIPTION <<<--- This is the only file needed to have an R package!
├── NAMESPACE
├── R
│   └── hello.R
...
└── man
    └── hello.Rd

Preliminaries

BiocManager::install(c('devtools', 'usethis'))

Links of interest

Workflow

Dataset

BRFSS:

brfss = read.csv('https://seandavi.github.io/ITR/BRFSS-subset.csv')

Code

#' Plot height vs weight in BRFSS
#'
#' @examples
#' plotHeightVsWeightBRFSS()
#'
#' @export
plotHeightVsWeightBRFSS = function() {
  data(brfss)
  plot(brfss$Height, brfss$Weight)
}
#' The Behavioral Risk Factor Surveillance System (BRFSS)
#'
#'The Behavioral Risk Factor Surveillance System (BRFSS) is
#'the nation’s premier system of health-related telephone surveys
#'that collect state data about U.S. residents regarding their
#'health-related risk behaviors, chronic health conditions, and
#'use of preventive services. Established in 1984 with 15 states,
#'BRFSS now collects data in all 50 states as well as the District
#'of Columbia and three U.S. territories. BRFSS completes more than
#'400,000 adult interviews each year, making it the largest
#'continuously conducted health survey system in the world.
#'
#' @format A data frame with 20000 rows and 5 variables:
#' \describe{
#'   \item{Age}{age in years}
#'   \item{Weight}{weight in kg}
#'   \item{Sex}{Gender, Female or Male}
#'   \item{Height}{height in cm}
#'   \item{Year}{Year in which person studied}
#' }
#' @source \url{https://www.cdc.gov/brfss/about/index.htm}
"brfss"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment