Title: | Accesses an Integrated Fish Count and Length Dataset from the San Francisco Delta |
---|---|
Description: | This package enables streamlined access to a large (45 million observation) integrated fish dataset from the San Fransisco Delta. The package downloads published data and stores it in parquet files as an `arrow` dataset in a local cache. Helper functions enable efficient querying of this large dataset. |
Authors: | Jeanette Clark [aut] , Samuel M Bashevkin [aut, cre] |
Maintainer: | Samuel M Bashevkin <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2024-11-27 02:53:09 UTC |
Source: | https://github.com/delta-stewardship-council/deltafish |
This function removes all cached files associated with the package
clear_cache()
clear_cache()
(NULL)
Close connection to SQLite database. Recommended at the end of every session.
close_database(con = NULL)
close_database(con = NULL)
con |
A DBI connection object from open_database() |
Collect data into R and convert dates/datetimes into the correct data types with the correct time zone.
It is recommended to use this function instead of collect
because the database RSQLite does not
support date and time data types, so they are stored as character vectors.
Although some date and time operations are still possible, when you collect
the dataset, the
Date and Datetime columns will be character vectors. This function will convert those columns
(if they exist in your collected dataset) into the correct date and datetime format.
RSQLite also does not have a logical data type and logical values are stored as integers.
Thus, the Secchi_estimated column is converted to logical by this function as well.
collect_data(data)
collect_data(data)
data |
A DBI table that can be treated like a data.frame. See |
Converts fish length data using the length conversion table. Returns an arrow dataset. This function is only needed to convert Suisun survey data.
convert_lengths(data)
convert_lengths(data)
data |
A DBI table that can be treated like a data.frame, with fish data. See |
data_conv A DBI table with converted lengths
## Not run: library(dplyr) con <- open_database() fish <- open_fish(con) %>% filter(Taxa %in% c("Dorosoma petenense", "Morone saxatilis", "Spirinchus thaleichthys")) fish_conv <- convert_lengths(fish) %>% collect() close_database(con) ## End(Not run)
## Not run: library(dplyr) con <- open_database() fish <- open_fish(con) %>% filter(Taxa %in% c("Dorosoma petenense", "Morone saxatilis", "Spirinchus thaleichthys")) fish_conv <- convert_lengths(fish) %>% collect() close_database(con) ## End(Not run)
Function to create the fish database. Reads in raw data from the published EDI dataset.
create_fish_db(edi_pid = NULL, update = FALSE, download_method = "curl")
create_fish_db(edi_pid = NULL, update = FALSE, download_method = "curl")
edi_pid |
(char) Optionally, a way to specify a specific revision of the dataset, in the format "edi.1075.1" Leave parameter unset to get the latest revision. |
update |
(logical) If set to TRUE, will update to latest version from EDI if a newer version is available |
download_method |
value for the |
Returns TRUE for up to date, FALSE if a newer version exists
is_cache_updated(cache_dir = "deltafish")
is_cache_updated(cache_dir = "deltafish")
cache_dir |
(char) The cache directory, by default set to deltafish for most use cases. |
(logical) Whether cache is up to date
Connect to the fish database stored in local cache directory.
open_database()
open_database()
con A DBI connection object
Connect to the fish table stored in the database
open_fish(con, quiet = FALSE)
open_fish(con, quiet = FALSE)
con |
A DBI connection object from open_database() |
quiet |
silence message about fish length units. |
A DBI table that can be treated like a data.frame, with fish data
Connect to the length conversion table stored in the database
open_length_conv(con)
open_length_conv(con)
con |
A DBI connection object from open_database() |
A DBI table that can be treated like a data.frame, with length conversion data
Connect to the survey table stored in the database
open_survey(con)
open_survey(con)
con |
A DBI connection object from open_database() |
A DBI table that can be treated like a data.frame, with survey data
Removes unknown fish lengths. Returns a DBI table.
remove_unknown_lengths(data, univariate)
remove_unknown_lengths(data, univariate)
data |
A DBI table that can be treated like a data.frame, with fish data. See |
univariate |
(logical) Will these data be used for univariate analyses
( |
data_known A DBI table with only known lengths
This function returns a list of files cached for the package.
show_cache()
show_cache()
(list) A list of files
This function returns the EDI revision number of the cached data.
show_cached_revision(cache_dir = "deltafish")
show_cached_revision(cache_dir = "deltafish")
cache_dir |
(char) The cache directory, by default set to deltafish for most use cases. |
(char) The revision number in the cache