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(data.table) | |
library(dplyr) | |
library(stringr) | |
# read data | |
dat = fread("all2013.csv") | |
fields = fread("fields.csv") | |
setnames(dat, fields$Header) | |
# processing datatable |
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(Rcpp) | |
library(inline) | |
cpp_code = " | |
using namespace Rcpp; | |
double piSugar(int N){ | |
RNGScope scope; | |
NumericVector x = runif(N); | |
NumericVector y = runif(N); | |
NumericVector d = sqrt(x*x + y*y); |
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(magrittr) | |
library(data.table) | |
library(ggplot2) | |
# pitch f/x data 2013 | |
dat = fread("2013.csv") | |
dat = dat %>% filter(sv_id !="NA") | |
# hit event |
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
d=data.frame(lt=c("blank", "solid", "dashed", "dotted", "dotdash", "longdash", "twodash", "1F", "F1", "4C88C488", "12345678")) | |
ggplot() + | |
scale_x_continuous(name="", limits=c(0,1), breaks=NA) + | |
scale_y_discrete(name="linetype") + | |
scale_linetype_identity() + | |
geom_segment(data=d, mapping=aes(x=0, xend=1, y=lt, yend=lt, linetype=lt)) |
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
playerID | careerHit | careerHit.x | careerHit.y | fullname | |
---|---|---|---|---|---|
aaronha01 | 3771 | 3771 | 3771 | Hank Aaron | |
ansonca01 | 3418 | 3418 | 3418 | Cap Anson | |
biggicr01 | 3060 | 3060 | 3060 | Craig Biggio | |
boggswa01 | 3010 | 3010 | 3010 | Wade Boggs | |
brettge01 | 3154 | 3154 | 3154 | George Brett | |
brocklo01 | 3023 | 3023 | 3023 | Lou Brock | |
carewro01 | 3053 | 3053 | 3053 | Rod Carew | |
clemero01 | 3000 | 3000 | 3000 | Roberto Clemente | |
cobbty01 | 4189 | 4189 | 4189 | Ty Cobb |
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(Lahman) | |
library(dplyr) | |
library(magrittr) | |
library(pings) | |
# Batting: season stats data frame of all the players | |
all_dat <- Batting %>% | |
select(yearID, AB, H, HR) %>% | |
group_by(yearID) %>% | |
dplyr::summarise(H = sum(H, na.rm = TRUE), |
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
df1 = data.frame(a = 1:3, b = 4:6, c = 7:9) | |
df2 = data.frame(c = 10:12, a = 13:15, b = 16:18) | |
merge(df1,df2, all=TRUE) | |
# a b c | |
# 1 1 4 7 | |
# 2 2 5 8 | |
# 3 3 6 9 | |
# 4 13 16 10 | |
# 5 14 17 11 |
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(data.table) | |
library(dplyr) | |
library(magrittr) | |
makedata = function(year = 2013){ | |
# set the path of data file | |
filename = paste("../../../data/all", year, ".csv", sep="") | |
dat = fread(filename, header=FALSE) | |
colnames = fread("names.csv", header = FALSE) %>% unlist | |
setnames(dat, colnames) |
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
for dir in `ls | grep [0-9]` | |
do | |
mv $dir"/"*.pdf $dir".pdf" | |
done | |
join.py --output out.pdf *.pdf |
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
\documentclass{article} | |
\usepackage[round]{natbib} | |
\usepackage{filecontents} | |
\begin{filecontents}{\jobname.bib} | |
@article {Schimd1993, | |
author = {Schmid, Hans-Peter and McNeal, John E. and Stamey, Thomas A.}, | |
title = {Observations on the doubling time of prostate cancer. The use of serial prostate-specific antigen in patients with untreated disease as a measure of increasing cancer volume}, | |
journal = {Cancer}, | |
volume = {71}, |
OlderNewer