| get_table | R Documentation |
Generic function to download data from any table in the WRDS database. Returns a lazy table by default, allowing you to build queries with dplyr before collecting.
get_table(wrds, library, table, columns = NULL, n = Inf, lazy = TRUE)
wrds |
A |
library |
Character. The name of the library (schema), e.g., |
table |
Character. The name of the table within the library. |
columns |
Character vector of columns to return. If |
n |
Maximum number of rows to return. Defaults to |
lazy |
If |
This function provides generic access to any WRDS table. For commonly-used tables with standard research filters, prefer the specialized functions:
get_compustat() for Compustat fundamentals with standard filters
get_company() for company header data
link_ccm() for CRSP-Compustat linking
The lazy table can be filtered, selected, and mutated using dplyr verbs, which are translated to SQL and executed on the server:
get_table(wrds, "crsp", "msf") |> filter(date >= "2025-01-01") |> select(permno, date, ret, prc) |> collect()
A tbl_lazy object (if lazy = TRUE) or a tibble (if lazy = FALSE).
describe_table() to explore table structure,
list_tables() to list available tables in a library
## Not run:
wrds <- wrds_connect()
# Preview table structure first
describe_table(wrds, "crsp", "msf")
# Get a lazy table and build your query
get_table(wrds, "crsp", "msf") |>
dplyr::filter(date >= "2025-01-01") |>
dplyr::select(permno, date, ret, prc, vol) |>
dplyr::collect()
# Collect immediately with specific columns
get_table(wrds, "crsp", "dsf",
columns = c("permno", "date", "ret", "prc"),
lazy = FALSE,
n = 1000
)
# Access any table in any library
get_table(wrds, "ibes", "statsum_epsus") |>
dplyr::filter(fpedats >= "2025-01-01") |>
dplyr::collect()
wrds_disconnect(wrds)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.