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
# NBA courts are 50ft sideline-to-sideline | |
# and 94ft end to end. This will plot a court | |
# with the sidelines on the y-axis, centered | |
# on the halfcourt circle. Measurement units | |
# are in feet. The basket at the bottom is | |
# centered on {x = 0, y = -41.75} and at the | |
# top on {x = 0, y = 41.75} | |
library(lattice) | |
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
# NCAA courts are 50ft sideline-to-sideline | |
# and 94ft end to end. This will plot a court | |
# with the sidelines on the y-axis, centered | |
# on the halfcourt circle. Measurement units | |
# are in feet. The basket at the bottom is | |
# centered on {x = 0, y = -41.75} and at the | |
# top on {x = 0, y = 41.75} | |
library(lattice) | |
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(stringr) | |
library(plyr) | |
library(car) | |
### the url of the player-season shooting page from basketball reference | |
url="http://www.basketball-reference.com/players/b/bryanko01/shooting/2015/" | |
dat=readLines(url) | |
dat=dat[grep("<div style=\"position:absolute;top:",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(ggplot2) | |
ggplot(data=data.frame(x=1,y=1),aes(x,y))+ | |
###outside box: | |
geom_path(data=data.frame(x=c(-25,-25,25,25,-25),y=c(-47,47,47,-47,-47)))+ | |
###halfcourt line: | |
geom_path(data=data.frame(x=c(-25,25),y=c(0,0)))+ | |
###halfcourt semicircle: | |
geom_path(data=data.frame(x=c(-6000:(-1)/1000,1:6000/1000),y=c(sqrt(6^2-c(-6000:(-1)/1000,1:6000/1000)^2))),aes(x=x,y=y))+ | |
geom_path(data=data.frame(x=c(-6000:(-1)/1000,1:6000/1000),y=-c(sqrt(6^2-c(-6000:(-1)/1000,1:6000/1000)^2))),aes(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(ggplot2) | |
ggplot(data=data.frame(x=1,y=1),aes(x,y))+ | |
###outside box: | |
geom_path(data=data.frame(x=c(-25,-25,25,25,-25),y=c(0,47,47,0,0)))+ | |
###solid FT semicircle above FT line: | |
geom_path(data=data.frame(x=c(-6000:(-1)/1000,1:6000/1000),y=c(19+sqrt(6^2-c(-6000:(-1)/1000,1:6000/1000)^2))),aes(x=x,y=y))+ | |
###dashed FT semicircle below FT line: | |
geom_path(data=data.frame(x=c(-6000:(-1)/1000,1:6000/1000),y=c(19-sqrt(6^2-c(-6000:(-1)/1000,1:6000/1000)^2))),aes(x=x,y=y),linetype='dashed')+ | |
###key: |