# R Dataset / Package plyr / baseball

Documentation |
---|

On this R-data statistics page, you will find information about the baseball data set which pertains to Yearly batting records for all major league baseball players. The baseball data set is found in the plyr R package. You can load the baseball data set in R by issuing the following command at the console data("baseball"). This will load the data into a variable called baseball. If R says the baseball data set is not found, you can try installing the package by issuing this command install.packages("plyr") and then attempt to reload the data. If you need to download R, you can go to the R project website. You can download a CSV (comma separated values) version of the baseball R data set. The size of this file is about 1,569,282 bytes. ## Yearly batting records for all major league baseball players## DescriptionThis data frame contains batting statistics for a subset of players collected from http://www.baseball-databank.org/. There are a total of 21,699 records, covering 1,228 players from 1871 to 2007. Only players with more 15 seasons of play are included. ## Usagebaseball ## FormatA 21699 x 22 data frame ## VariablesVariables: -
id, unique player id -
year, year of data -
stint -
team, team played for -
lg, league -
g, number of games -
ab, number of times at bat -
r, number of runs -
h, hits, times reached base because of a batted, fair ball without error by the defense -
X2b, hits on which the batter reached second base safely -
X3b, hits on which the batter reached third base safely -
hr, number of home runs -
rbi, runs batted in -
sb, stolen bases -
cs, caught stealing -
bb, base on balls (walk) -
so, strike outs -
ibb, intentional base on balls -
hbp, hits by pitch -
sh, sacrifice hits -
sf, sacrifice flies -
gidp, ground into double play
## Referenceshttp://www.baseball-databank.org/ ## Examplesbaberuth <- subset(baseball, id == "ruthba01") baberuth$cyear <- baberuth$year - min(baberuth$year) + 1calculate_cyear <- function(df) { mutate(df, cyear = year - min(year), cpercent = cyear / (max(year) - min(year)) ) }baseball <- ddply(baseball, .(id), calculate_cyear) baseball <- subset(baseball, ab >= 25)model <- function(df) { lm(rbi / ab ~ cyear, data=df) } model(baberuth) models <- dlply(baseball, .(id), model) -- Dataset imported from https://www.r-project.org. |

Title | Authored on | Content type |
---|---|---|

OpenIntro Statistics Dataset - dream | August 9, 2020 - 12:25 PM | Dataset |

OpenIntro Statistics Dataset - winery_cars | August 9, 2020 - 2:38 PM | Dataset |

R Dataset / Package HSAUR / toothpaste | March 9, 2018 - 1:06 PM | Dataset |

R Dataset / Package HSAUR / pottery | March 9, 2018 - 1:06 PM | Dataset |

R Dataset / Package HistData / Guerry | March 9, 2018 - 1:06 PM | Dataset |

Attachment | Size |
---|---|

dataset-89446.csv | 1.5 MB |