Title: | Import, Clean and Update Data from the New Zealand Freshwater Fish Database |
---|---|
Description: | Access the New Zealand Freshwater Fish Database from R and a few functions to clean the data once in R. |
Authors: | Finnbar Lee [aut, cre], Nick Young [aut] |
Maintainer: | Finnbar Lee <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.1.0 |
Built: | 2024-11-08 03:56:56 UTC |
Source: | https://github.com/flee598/nzffdr |
Add year, month and day columns to a NZFFD dataset.
nzffdr_add_dates(fishd)
nzffdr_add_dates(fishd)
fishd |
a dataframe imported from the NZFFD using |
Adds year, month and day columns to a NZFFD dataset, based on values in the "eventDate" column.
a NZFFD dataframe, with year, month and day columns added.
nzffdr_add_dates(nzffdr::nzffdr_data)
nzffdr_add_dates(nzffdr::nzffdr_data)
Clean up data imported from the NZ Freshwater Fish Database.
nzffdr_clean(fishd)
nzffdr_clean(fishd)
fishd |
a dataframe imported from the NZFFD using |
Cleans up a few inconsistencies in the NZFFD data returned from
nzffd_import()
. Column types are checked and converted to, integer,
numeric or character. Empty cells are filled with NA, variable 'catchmentName'
entries are standardised (e.g. Clutha r, Clutha River and Clutha R all
become Clutha R) and, any empty columns are removed.
A cleaned NZFFD dataframe.
nzffdr_clean(nzffdr::nzffdr_data)
nzffdr_clean(nzffdr::nzffdr_data)
Sample NZFFD data.
data(nzffdr_data)
data(nzffdr_data)
A dataframe of 200 rows and 67 variables.
Lists of possible argument options for function nzffdr_import()
.
nzffdr_get_table(x = c("fish_method", "institution", "taxon"))
nzffdr_get_table(x = c("fish_method", "institution", "taxon"))
x |
one of "fish_method", "institution" or "taxon", depending on which argument values are wanted. |
Returns the possible argument values for arguments: fish_method,
institution and taxon, used in the function nzffdr_import()
.
This function requires an internet connection to query NIWA's database.
A dataframe or character string of argument options.
## Not run: dat <- nzffdr_get_table("taxon") ## End(Not run)
## Not run: dat <- nzffdr_get_table("taxon") ## End(Not run)
Import data from the NZ Freshwater Fish Database. Enter search terms as arguments as you would in the NZFFD and import directly into R. You can search using all the same query options which are used for in the NZFFFD, see their info page for details. To import the entire database leave all arguments as default.
nzffdr_import( institution = "", catchment_num = "", catchment_name = "", water_body = "", fish_method = "", taxon = "", starts = "", ends = "", download_format = "all" )
nzffdr_import( institution = "", catchment_num = "", catchment_name = "", water_body = "", fish_method = "", taxon = "", starts = "", ends = "", download_format = "all" )
institution |
institution that collected the data. Use the
|
catchment_num |
catchment number. A 6 digit number unique to the reach of
interest. You can search using the individual number (e.g. |
catchment_name |
catchment name. e.g. |
water_body |
water body name. e.g. to get all records for Limestone
Creek, |
fish_method |
fishing method used. Use the |
taxon |
taxon of interest. Use the |
starts |
start year. Don't set the arg if you want all records in the database. |
ends |
end year. Don't set the arg if you want all records in the database. |
download_format |
use "all" or "essential" to download either, all variables (67 columns), which now includes some River Environment Classification data, or just essential data (23 columns). |
This function requires an internet connection to query NIWA's database.
Data citation: Stoffels R (2022). New Zealand Freshwater Fish Database (extended). The National Institute of Water and Atmospheric Research (NIWA). Sampling event dataset https://doi.org/10.15468/jbpw92
A dataframe where each row is a NZFFD record.
## Not run: # import entire NZFFD dat <- nzffdr_import() ## End(Not run)
## Not run: # import entire NZFFD dat <- nzffdr_import() ## End(Not run)
Converts individual fish length measures from multiple entries in a single cell to tidy long format.
nzffdr_ind_lengths(fishd)
nzffdr_ind_lengths(fishd)
fishd |
an NZFFD dataframe returned from nzffdr_import(). Must contain the columns "nzffdRecordNumber", "taxonName" and "indLengths". |
A dataframe with three columns,"nzffdRecordNumber", "taxonName" and "indLengths".
nzffdr_ind_lengths(nzffdr::nzffdr_data)
nzffdr_ind_lengths(nzffdr::nzffdr_data)
A simple features map of New Zealand. A simplified version of the 1:150k NZ map outline available from Land Information New Zealand. CRS: NZ Transverse Mercator (NZTM: EPSG 2193).
nzffdr_nzmap
nzffdr_nzmap
A simple features dataframe with 4 rows and 2 columns:
Island name
Line geometry
Wraps multiple nzffdr functions allowing, importing, cleaning and adding of new information all in one step.
nzffdr_razzle_dazzle()
nzffdr_razzle_dazzle()
Wraps: [nzffdr_import()], [nzffdr_clean()], [nzffdr_add_date()], [nzffdr_taxon_threat()], [nzffdr_widen_habitat()] and runs the lot in one go, returning a downloaded and cleaned NZFFD dataset.
This function requires an internet connection to query the NZFFD
An NZFFD dataframe which has been cleaned and had date, taxonomic and threat classification status data added.
## Not run: dat <- nzffdr_razzle_dazzle() ## End(Not run)
## Not run: dat <- nzffdr_razzle_dazzle() ## End(Not run)
Adds additional common and scientific names, and threat classification status information.
nzffdr_taxon_threat(fishd)
nzffdr_taxon_threat(fishd)
fishd |
A dataframe imported from the NZFFD using |
Adds additional taxonomic data ("commonMaoriName", "alternativeNames", "species", "genus", "family", "order", "class", "phylum") and NZ Threat Classification Status information ("category", "status", "taxonomicStatus", "bioStatus"). See NZTCS for details regarding the NZTCS variables.
An NZFFD dataframe, with 12 additional columns.
nzffdr_taxon_threat(nzffdr::nzffdr_data)
nzffdr_taxon_threat(nzffdr::nzffdr_data)
Converts habitat variables to tidy wide format columns and appends to original dataframe. Warning, with large (>100k rows) datasets this function slow (~30 seconds).
nzffdr_widen_habitat( fishd, cols_to_expand = c("habitatFlowPercent", "habitatInstreamCoverPresent", "habitatRiparianVegPercent", "habitatSubstratePercent") )
nzffdr_widen_habitat( fishd, cols_to_expand = c("habitatFlowPercent", "habitatInstreamCoverPresent", "habitatRiparianVegPercent", "habitatSubstratePercent") )
fishd |
an NZFFD dataframe returned from nzffdr_import. |
cols_to_expand |
the habitat columns to expand, can be any combination of "habitatFlowPercent", "habitatInstreamCoverPresent", "habitatRiparianVegPercent", "habitatSubstratePercent". |
An NZFFD dataframe with added wide format columns for each of the selected habitat columns.
nzffdr_widen_habitat(nzffdr::nzffdr_data)
nzffdr_widen_habitat(nzffdr::nzffdr_data)