Title: | Import, Clean and Update Data from the New Zealand Freshwater Fish Database |
Version: | 2.1.0 |
Description: | Access the New Zealand Freshwater Fish Database from R and a few functions to clean the data once in R. |
License: | MIT + file LICENSE |
Depends: | R (≥ 4.0.0) |
Imports: | curl, httr, rlang, stringi, tidyr, utils, xml2 |
Suggests: | devtools, knitr, rmarkdown, roxygen2, |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.2.1 |
URL: | https://flee598.github.io/nzffdr/ |
NeedsCompilation: | no |
Packaged: | 2022-11-08 06:46:18 UTC; Finn |
Author: | Finnbar Lee [aut, cre], Nick Young [aut] |
Maintainer: | Finnbar Lee <lee.finnbar@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2022-11-08 09:50:02 UTC |
Add dates to a NZFFD dataset
Description
Add year, month and day columns to a NZFFD dataset.
Usage
nzffdr_add_dates(fishd)
Arguments
fishd |
a dataframe imported from the NZFFD using |
Details
Adds year, month and day columns to a NZFFD dataset, based on values in the "eventDate" column.
Value
a NZFFD dataframe, with year, month and day columns added.
Examples
nzffdr_add_dates(nzffdr::nzffdr_data)
Clean NZ Freshwater Fish Datasets
Description
Clean up data imported from the NZ Freshwater Fish Database.
Usage
nzffdr_clean(fishd)
Arguments
fishd |
a dataframe imported from the NZFFD using |
Details
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.
Value
A cleaned NZFFD dataframe.
Examples
nzffdr_clean(nzffdr::nzffdr_data)
Sample NZFFD data.
Description
Sample NZFFD data.
Usage
data(nzffdr_data)
Format
A dataframe of 200 rows and 67 variables.
Source
Get NZFFD search terms
Description
Lists of possible argument options for function nzffdr_import()
.
Usage
nzffdr_get_table(x = c("fish_method", "institution", "taxon"))
Arguments
x |
one of "fish_method", "institution" or "taxon", depending on which argument values are wanted. |
Details
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.
Value
A dataframe or character string of argument options.
Examples
## Not run:
dat <- nzffdr_get_table("taxon")
## End(Not run)
Import NZ Freshwater Fish datasets.
Description
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.
Usage
nzffdr_import(
institution = "",
catchment_num = "",
catchment_name = "",
water_body = "",
fish_method = "",
taxon = "",
starts = "",
ends = "",
download_format = "all"
)
Arguments
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). |
Details
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
Value
A dataframe where each row is a NZFFD record.
Examples
## Not run:
# import entire NZFFD
dat <- nzffdr_import()
## End(Not run)
Fish length to tidy long format
Description
Converts individual fish length measures from multiple entries in a single cell to tidy long format.
Usage
nzffdr_ind_lengths(fishd)
Arguments
fishd |
an NZFFD dataframe returned from nzffdr_import(). Must contain the columns "nzffdRecordNumber", "taxonName" and "indLengths". |
Value
A dataframe with three columns,"nzffdRecordNumber", "taxonName" and "indLengths".
Examples
nzffdr_ind_lengths(nzffdr::nzffdr_data)
Simple features map of New Zealand
Description
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).
Usage
nzffdr_nzmap
Format
A simple features dataframe with 4 rows and 2 columns:
- island
Island name
- geometry
Line geometry
Source
Wrapper for multiple nzffdr functions
Description
Wraps multiple nzffdr functions allowing, importing, cleaning and adding of new information all in one step.
Usage
nzffdr_razzle_dazzle()
Details
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
Value
An NZFFD dataframe which has been cleaned and had date, taxonomic and threat classification status data added.
Examples
## Not run:
dat <- nzffdr_razzle_dazzle()
## End(Not run)
Add taxonomic and threat status data
Description
Adds additional common and scientific names, and threat classification status information.
Usage
nzffdr_taxon_threat(fishd)
Arguments
fishd |
A dataframe imported from the NZFFD using |
Details
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.
Value
An NZFFD dataframe, with 12 additional columns.
Examples
nzffdr_taxon_threat(nzffdr::nzffdr_data)
Converts habitat variables to tidy wide format
Description
Converts habitat variables to tidy wide format columns and appends to original dataframe. Warning, with large (>100k rows) datasets this function slow (~30 seconds).
Usage
nzffdr_widen_habitat(
fishd,
cols_to_expand = c("habitatFlowPercent", "habitatInstreamCoverPresent",
"habitatRiparianVegPercent", "habitatSubstratePercent")
)
Arguments
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". |
Value
An NZFFD dataframe with added wide format columns for each of the selected habitat columns.
Examples
nzffdr_widen_habitat(nzffdr::nzffdr_data)