This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(dplyr) | |
library(gridExtra) | |
dat <- read.csv("data/burst.csv") # generated by Sci2 | |
dat$idx <- rownames(dat) | |
dat$size <- dat$Weight / dat$Length | |
gg <- ggplot(dat, aes(x=Start, xend=End, y=reorder(idx, Start), yend=idx)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(shinydashboard) | |
library(sparkline) | |
library(httr) | |
library(jsonlite) | |
library(data.table) | |
library(dplyr) | |
library(rvest) | |
library(magrittr) | |
library(XML) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a <- -.6 #slope | |
j <- 0 | |
for (a in seq(-3, 3, by=0.1)) { | |
b <- .3 #intercept | |
timeserieslength <- 10 #Number of iterations | |
y1 <- .3 #initial Value | |
y2 <- 0 | |
t <- 0 | |
for (i in 1:timeserieslength) { | |
y2[i] <- (a*y1[i])+b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rvest) | |
library(dplyr) | |
library(ggplot2) | |
url <- "http://www.bloomberg.com/visual-data/best-and-worst//most-registered-guns-per-capita-states" | |
pg <- html(url) | |
tab <- pg %>% html_nodes("table") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(tidyr) | |
dat <- as.data.frame(matrix(rep(c(rep("A", 24), rep("B", 8)), 10), nrow=10, byrow=TRUE)) | |
dat$y <- rownames(dat) | |
dat %>% | |
gather(x, value, -y) %>% | |
mutate(x=as.numeric(gsub("V", "", x))) -> dat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(ggplot2) | |
shinyServer(function(input, output) { | |
dat <- data.frame(t=seq(0, 5*pi, by=0.01)) | |
xhrt <- function(t) 16*sin(t)^3 | |
yhrt <- function(t) 13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(mosaic) | |
duration <- 40 | |
plot.new() | |
soln <- integrateODE(dD~(1.05*(D-600)) * (1-(D/1300)), D=797, tdur=duration) | |
plotFun(soln$D(t)~t, tlim=range(1, duration), col="red", | |
xlab="Years out", ylab="Population (thousands)", main="Deer population model", | |
ylim=c(0, 1500)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(streamgraph) | |
library(pbapply) | |
# Grab some employment data from BLS -------------------------------------- | |
url <- "http://www.bls.gov/lau/ststdsadata.txt" | |
dat <- readLines(url) | |
# Small function to grab data for a particular state ---------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
library(rvest) | |
library(streamgraph) | |
library(htmltools) | |
# I'm using disastecenter.com since the FBI API is stupid. I should just wrap | |
# this into a data package at some point | |
get_crime <- function(state) { |