This file contains hidden or 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) | |
# make dataframe | |
x <- seq(0,3, by = 0.1) | |
y <- x^2 | |
xy <- data.frame(x = x, y = y) | |
# plot | |
p <- ggplot() | |
p <- p + geom_line(data = xy, aes(x = x, y = y)) |
This file contains hidden or 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/python | |
# -*- coding: utf-8 -*- | |
import re | |
import urllib | |
from BeautifulSoup import BeautifulSoup | |
html = ''' | |
上記HTML。ここに書くと表示が乱れるので分けました。 | |
''' |
This file contains hidden or 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(pitchRx) | |
library(ggplot2) | |
library(data.table) | |
library(dplyr) | |
# データ取得 | |
# data = scrapeFX("2013-01-01", "2013-10-01") | |
# 取得済みデータの利用 | |
# data <- fread("2013.csv") |
This file contains hidden or 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(plyr) | |
library(dplyr) | |
master = fread("Master.csv") | |
master$fullname = with(master, paste(nameFirst, nameLast)) | |
name_id_data = with(master, data.frame(name = fullname, PIT_ID = retroID)) | |
season_babip <- function(year){ | |
filename = paste("all", year, ".csv", sep="") |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) | |
library(kernlab) | |
library(dplyr) | |
library(magrittr) | |
shinyServer(function(input, output){ | |
output$distPlot = reactivePlot(function(){ | |
param = 10 ^ input$param | |
#package 'kernlab' = kernel pca |
This file contains hidden or 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 |