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
#! /usr/bin/env Rscript | |
#start an instance | |
startup <- system("ec2-run-instances ami-b232d0db -k ec2ApiTools", intern=T) | |
Sys.sleep(45) #rather random but 45 seconds is typically long enough to boot | |
#query running instances | |
instances <- system("ec2-describe-instances", intern=T) | |
instancesParsed <- sapply(instances, strsplit, "\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
set.seed(2) | |
x <- 1:100 | |
y <- 20 + 3 * x | |
e <- rnorm(100, 0, 60) | |
y <- 20 + 3 * x + e | |
plot(x,y) | |
yx.lm <- lm(y ~ x) | |
lines(x, predict(yx.lm), col="red") |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<medals xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.sportradar.com/sportsapi/v1/winterolympics" generated_at="2017-12-03T12:23:38+01:00" xsi:schemaLocation="http://schemas.sportradar.com/sportsapi/v1/winterolympics http://schemas.sportradar.com/bsa/winterolympics/v1/xml/endpoints/winterolympics/medals.xsd"> | |
<medals_by_country> | |
<medal_info country="Slovenia" country_code="SLO" ioc_code="SLO" total_ranking="1" gold_ranking="1" total="24" gold="14" silver="3" bronze="7"/> | |
<medal_info country="Canada" country_code="CAN" ioc_code="CAN" total_ranking="2" gold_ranking="1" total="17" gold="9" silver="5" bronze="3"/> | |
<medal_info country="Germany" country_code="GER" ioc_code="GER" total_ranking="3" gold_ranking="1" total="19" gold="8" silver="6" bronze="5"/> | |
<medal_info country="USA" country_code="USA" ioc_code="USA" total_ranking="4" gold_ranking="1" total="17" gold="5" silver="8" bronze="4"/> | |
<medal_info country="Russia" coun |
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
# multivariate normal example using Cholesky decomposition | |
require(Matrix) | |
#make this reproducible | |
set.seed(2) | |
#how many draws in our starting data set? | |
n <- 1e4 |
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
## Joshua Ulrich's pivot function | |
## This code is alpha and is in development. | |
## please test all results to ensure accuracy | |
pivot <- function(x, rows, cols, FUN=NULL) { | |
clean <- function(xx, dd) { | |
cd <- merge(dd,xx,by=0,all=TRUE) | |
rownames(cd) <- cd$Row.names | |
cd$Row.names <- NULL | |
return(cd) |
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
## make some non norm data | |
d1 <- rnorm(20, 5, 1) | |
d2 <- rnorm(5, 10, 2) | |
d <- c(d1,d2) | |
hist(d) | |
## no mean adjustment | |
myUniform <- ecdf( d )( d ) | |
mean( myUniform ) | |
## hey that mean's not .5! |
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
--- | |
title: "Markdown Y'All" | |
author: "James Long" | |
date: "March 27, 2018" | |
output: | |
html_document: default | |
pdf_document: default | |
word_document: default | |
--- |
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
#draw.circle is from the plotrix library | |
require(plyr) | |
draw.circle <- function (x, y, radius, nv = 100, border = NULL, col = NA, lty = 1, | |
lwd = 1) | |
{ | |
xylim <- par("usr") | |
plotdim <- par("pin") | |
ymult <- (xylim[4] - xylim[3])/(xylim[2] - xylim[1]) * plotdim[1]/plotdim[2] | |
angle.inc <- 2 * pi/nv |
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
query <- "SELECT uid, | |
timestamp, | |
sensor_1 | |
FROM database_name.long_table_name_here | |
WHERE ( ( uid = 'abxyz1230' | |
AND filter_id = '1' | |
AND timestamp >= '2018-07-23' | |
AND timestamp <= '2018-08-02' ) | |
OR ( uid = 'abxyz1236' | |
AND filter_id = '1' |
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(analogsea) | |
library(tidyverse) | |
library(furrr) | |
cluster_tag <- 'r_cluster' | |
cluster_prefix <- 'node-' | |
number_of_nodes <- 2 | |
# Path to private SSH key that matches key uploaded to DigitalOcean | |
# it looks like ~ does not work here... not sure why | |
ssh_private_key_file <- "/Users/jal/.ssh/id_rsa" |
NewerOlder