Skip to content

Instantly share code, notes, and snippets.

@seankross
seankross / expected.R
Created September 22, 2017 20:33
For Stephan
steph <- structure(c(148L, 65L, 198L, 53L, 16L, 2004L), .Dim = c(3L, 2L
), .Dimnames = structure(list(c("EatNoTrans", "Request", "Stealing"
), c("0", "1")), .Names = c("", "")), class = "table")
chisq_steph <- chisq.test(steph)
chisq_steph$expected
@seankross
seankross / install_ffmpeg_ubuntu.sh
Last active September 14, 2024 01:22 — forked from xdamman/install_ffmpeg_ubuntu.sh
Install latest ffmpeg on ubuntu 12.04 or 14.04
#!/bin/bash
# Bash script to install latest version of ffmpeg and its dependencies on Ubuntu 12.04 or 14.04
# Inspired from https://gist.github.com/faleev/3435377
# Remove any existing packages:
sudo apt-get -y remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
# Get the dependencies (Ubuntu Server or headless users):
sudo apt-get update
library(dplyr)
library(purrr)
set.seed(2017-06-27)
# Imagine this function gives us measurements from nature
data_generator <- function(n = 500){
data_frame(var1 = rnorm(500)) %>%
mutate(var2 = var1 + rnorm(500)) %>%
mutate(var3 = var1 * var2 + rnorm(500)) %>%
library(aws.polly)
jeff <- synthesize("Hello, I am Jeff Leek. Take a look at this chart on my left.", "Joey")
plot(jeff@left, type = "l")
library(dplyr)
x <- mtcars %>%
group_by(cyl) %>%
sample_frac(replace = TRUE)
mtcars %>%
group_by(cyl) %>%
summarise(sum = n())
@seankross
seankross / app.R
Created June 5, 2017 16:21
rOpenSci Unconf Issue Browser
library(gh)
library(jsonlite)
library(purrr)
library(tibble)
library(dplyr)
library(shiny)
library(plotly)
# You can create a GitHub PAT here: https://github.com/settings/tokens
Sys.setenv(GITHUB_PAT = "")
library(shiny)
library(dplyr)
delete_last_row <- function(df){
df[1:(nrow(df) - 1),]
}
ui <- basicPage(
plotOutput("plot1", click = "plot_click", dblclick = "plot_dblclick")
)
library(dplyr)
mtcars %>%
group_by(cyl) %>%
summarize(mean(disp))
# # A tibble: 3 × 2
# cyl `mean(disp)`
# <dbl> <dbl>
# 1 4 105.1364
library(dplyr)
mtcars %>%
group_by(cyl) %>%
summarize(mean(disp))
# # A tibble: 3 × 2
# cyl `mean(disp)`
# <dbl> <dbl>
# 1 4 105.1364
library(dplyr)
mtcars %>%
group_by(cyl) %>%
summarize(mean(disp))
# # A tibble: 3 × 2
# cyl `mean(disp)`
# <dbl> <dbl>
# 1 4 105.1364