Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lahman

Cache and retrieve an src_sqlite of the Lahman baseball database.


Description

This creates an interesting database using data from the Lahman baseball data source, provided by Sean Lahman at http://www.seanlahman.com/baseball-archive/statistics/, and made easily available in R through the Lahman package by Michael Friendly, Dennis Murphy and Martin Monkman. See the documentation for that package for documentation of the individual tables.

Usage

lahman_sqlite(path = NULL)

lahman_postgres(dbname = "lahman", host = "localhost", ...)

lahman_mysql(dbname = "lahman", ...)

copy_lahman(con, ...)

has_lahman(type, ...)

lahman_srcs(..., quiet = NULL)

Arguments

...

Other arguments passed to src on first load. For MySQL and PostgreSQL, the defaults assume you have a local server with lahman database already created. For lahman_srcs(), character vector of names giving srcs to generate.

type

src type.

quiet

if TRUE, suppress messages about databases failing to connect.

Examples

# Connect to a local sqlite database, if already created

library(dplyr)

if (has_lahman("sqlite")) {
  lahman_sqlite()
  batting <- tbl(lahman_sqlite(), "Batting")
  batting
}

# Connect to a local postgres database with lahman database, if available
if (has_lahman("postgres")) {
  lahman_postgres()
  batting <- tbl(lahman_postgres(), "Batting")
}

dbplyr

A 'dplyr' Back End for Databases

v2.1.1
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre], Maximilian Girlich [aut], Edgar Ruiz [aut], RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.