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

hy_src

Open a connection to the HYDAT database


Description

This function gives low-level access to the underlying HYDAT database used by other functions. Many of these tables are too large to load into memory, so it is best to use dplyr to filter them before using collect to read them into memory.

Usage

hy_src(hydat_path = NULL)

hy_src_disconnect(src)

Arguments

hydat_path

The path to the hydat database or NULL to use the default location used by download_hydat. It is also possible to pass in an existing src_sqlite such that the database only needs to be opened once per user-level call.

src

A src_sqlite as returned by hy_src().

Value

A dplyr src_sqlite

See Also

Examples

## Not run: 
library(dplyr)

# src is a src_sqlite
src <- hy_src(hydat_path = hy_test_db())
src_tbls(src)

# to get a table, use dplyr::tbl()
tbl(src, "STATIONS")

# one you're sure the results are what you want
# get a data.frame using collect()
tbl(src, "STATIONS") %>%
  filter(PROV_TERR_STATE_LOC == "BC") %>%
  collect()
  
# close the connection to the database
hy_src_disconnect(src)

## End(Not run)

tidyhydat

Extract and Tidy Canadian 'Hydrometric' Data

v0.5.2
Apache License (== 2.0) | file LICENSE
Authors
Sam Albers [aut, cre] (<https://orcid.org/0000-0002-9270-7884>), David Hutchinson [ctb], Dewey Dunnington [ctb], Ryan Whaley [ctb], Province of British Columbia [cph], Luke Winslow [rev] (Reviewed for rOpenSci), Laura DeCicco [rev] (Reviewed for rOpenSci)
Initial release

We don't support your browser anymore

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