Skip to content

Instantly share code, notes, and snippets.

@vpnagraj
vpnagraj / app.R
Created January 26, 2016 17:33
trivial shiny app with file download handler
library(shiny)
library(dplyr)
server <- function(input, output) {
output$downloadData <- downloadHandler(
filename = function() {
paste('data_', Sys.Date(), '.csv', sep='')
},
@vpnagraj
vpnagraj / outlier_rm.R
Last active February 5, 2016 17:20
shiny gadget that removes outliers based on 'brushed' area of a plot
# install.packages("shiny")
# install.packages("miniUI")
# install.packages("ggplot2")
library(shiny)
library(miniUI)
library(ggplot2)
outlier_rm <- function(data, xvar, yvar) {
ui <- miniPage(
@vpnagraj
vpnagraj / panderlatexpost.Rmd
Created March 3, 2016 20:44
example of an rmarkdown document that uses latex syntax in pander table headings
---
title: "RMarkdown(Pandoc(LaTeX))"
author: "VP Nagraj"
date: "March 3, 2016"
output:
html_document:
keep_md: yes
---
```{r, warning=FALSE, message=FALSE}
# list manipulation workshop
# scratch script
# november 9 2016
#############################################
slamwins <- list(17,14,14,12,11)
#############################################
# script to demonstrate outbreak animation with a subset of mers_korea_2015 data
# must install github release of threejs package
# devtools::install_github("bwlewis/rthreejs")
library(threejs)
library(outbreaks)
library(dplyr)
# use dplyr to subset results to only include hospital visit exposure
@vpnagraj
vpnagraj / outbreak_animation_list.R
Created June 16, 2017 17:04
script to demonstrate outbreak animation with a subset of mers_korea_2015 data
# script to demonstrate outbreak animation with a subset of mers_korea_2015 data
# must install github release of threejs package
# devtools::install_github("bwlewis/rthreejs")
library(threejs)
library(outbreaks)
library(dplyr)
# use dplyr to subset results to only include hospital visit exposure
@vpnagraj
vpnagraj / scales.R
Created January 4, 2018 16:52
scale exploration
library(ggplot2)
library(tidyr)
dat <- data.frame(x = rnorm(n = 1000, mean = 2.8, sd = 0.05),
y1 = sample(64503:73034, size = 1000, replace = TRUE),
y2 = sample(18738:19602, size = 1000, replace = TRUE))
dat %>%
ggplot() +
geom_point(aes(x,y1)) +
@vpnagraj
vpnagraj / scratch.R
Last active January 25, 2018 15:07
files for shiny workshop
# install.packages("babynames")
library(babynames)
# install.packages("tidyverse")
library(tidyverse)
# install.packages("ggplot2")
# install.packages("dplyr")
# let's take a look at the data
babynames %>%
View()
@vpnagraj
vpnagraj / moma.Rmd
Created February 29, 2016 21:41
rmarkdown with embedded shiny app
---
title: "MOMA"
author: "VP Nagraj"
date: "February 29, 2016"
output: html_document
runtime: shiny
---
The Museum of Modern Art (MOMA) collection database is publicly available via Github:
@vpnagraj
vpnagraj / benchmark.R
Created July 4, 2018 15:45
benchmarking `svSocket` versus base `load` versus `redis`
library(microbenchmark)
library(redux)
library(svSocket)
# clear workspace
rm(list = ls())
# set up svSocket
startSocketServer()
con <- socketConnection(host = "localhost", port = 8888, blocking = FALSE)