Skip to content

Instantly share code, notes, and snippets.

View wibeasley's full-sized avatar
🪢

Will Beasley wibeasley

🪢
View GitHub Profile
@wibeasley
wibeasley / example-r-markdown.rmd
Created September 4, 2012 15:15 — forked from jeromyanglim/example-r-markdown.rmd
Example of using R Markdown
This post examines the features of [R Markdown](http://www.rstudio.org/docs/authoring/using_markdown)
using [knitr](http://yihui.name/knitr/) in Rstudio 0.96.
This combination of tools provides an exciting improvement in usability for
[reproducible analysis](http://stats.stackexchange.com/a/15006/183).
Specifically, this post
(1) discusses getting started with R Markdown and `knitr` in RStudio 0.96;
(2) provides a basic example of producing console output and plots using R Markdown;
(3) highlights several code chunk options such as caching and controlling how input and output is displayed;
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and
(5) discusses the implications of R Markdown.
@wibeasley
wibeasley / storedProcedures.R
Last active May 17, 2018 13:51 — forked from tbobin/storedProcedures.R
Execute stored procedures from R with odbc and DBI
library(tidyverse)
library(DBI)
library(odbc)
# connect to database
cn <- dbConnect(odbc::odbc(), driver = "ODBC Driver 13 for SQL Server",
server="MYSQLSERVER\\SQLEXPRESS",
database = "myTestDB",
Trusted_Connection="Yes")
@wibeasley
wibeasley / package-janitor-bbmc.R
Last active January 16, 2020 05:37
Install packages typically needed by the BBMC data analysts (https://github.com/OuhscBbmc)
#' This code checks the user's installed packages against the packages listed in
#' https://github.com/OuhscBbmc/RedcapExamplesAndPatterns/blob/master/utility/package-dependency-list.csv
#' These packages are necessary for most of the analyses run by the OUHSC BBMC (https://github.com/OuhscBbmc).
#'
#' CRAN packages are installed only if they're not already; then they're updated if available.
#' GitHub packages are installed regardless if they're already installed.
#'
#' If anyone encounters a package that should be on there, please add it to
#' https://github.com/OuhscBbmc/RedcapExamplesAndPatterns/blob/master/utility/package-dependency-list.csv
#'
@wibeasley
wibeasley / intersection.R
Created February 9, 2020 05:57
Finding & graphing the intersection between two lines
f1 <- function(x) (3*x - 40) / 10
f2 <- function(x) (-20 - 2*x) / 2
# f1 <- function(x) (24000 - 200*x) / 350
# f2 <- function(x) (130 - x) / 2
x_limits <- c(-10, 100)
########## Don't change anything below this line #########################
g <- function(x) f1(x) - f2(x)
y_range <- range(0, f1(x_limits), f2(x_limits))