Returns the HLI table with some additional metadata, such as NMFS_PopID and update dates, in the default tabletype="xport case. This is the table that one can download from the CAP Fish HLIs Tabular Query. The HLI is specified using its short code:

  • NOSA: Natural Origin Spawner Abundance

  • SAR: Smolt to Adult Ratios

  • PNI: Proportionate Natural Influence of supplementation hatcheries

  • RperS: Recruits per Spawner

  • JuvOut: Juvenile Outmigrants

  • PreSmolt: Presmolt Abundance

The query will download 1000 records by default; you can change this by passing in qlist=list(limit=1100) for example. To make a filtered query e.g. for one ESU or popid) pass in the flist argument. Field names and values are case insensitive, e.g. POPID, popid and PopID return the same result. If your filter value is not in the table, the returned table will be empty. Examples:

  • flist=list(popid=7) return values for popid 7.

  • flist=list(nmfs_popid=6) return values for NMFS_PopID 6.

  • flist=list(esu_dps="Salmon, Chinook (Snake River spring/summer-run ESU)") return values for one ESU. Use rCAX:::caxesu to see a list of ESU_DPS names.

rcax_hli(
  hli = c("NOSA", "SAR", "PNI", "PreSmolt", "JuvOut", "RperS"),
  flist = NULL,
  qlist = NULL,
  cols = NULL,
  sortcols = NULL,
  type = c("data.frame", "colnames"),
  tabletype = c("xport", "base"),
  GETargs = list(table_id = NULL, recordloc = "records", key = NULL, parse = TRUE),
  ...
)

Arguments

hli

The HLI short name: NOSA, SAR, PNI, PreSmolt, JuvOut, RperS

flist

A filter for the query. See details and rcax_filter()

qlist

Additional query parameters. See rcax_table_query() for details.

cols

column names to return. Use cols=NULL if you want all columns. Names are case insensitive.

sortcols

The columns to sort on for the returned table. The order of sortcols indicates the order of sorting. Start with the smallest group and work outwards, e.g. c("spawningyear", "popid", "MPG"). Names are case insensitive.

type

whether to return the table ("data.frame") or colnames with definitions ("colnames"). Default is to return the table as a data frame.

tabletype

"xport" (default) or "base". XPort has additional useful metadata.

GETargs

A list of arguments for the rcax_GET() call. These do not need to be specified by the user unless the user wants to change the default values. table_id This is the CAX table id. It is looked up using tablename and rCAX:::caxpops (an internal dataset). If table_id is passed in via GETargs, it will override the default table id lookup. recordloc This is the name of the record we want in the list returned from the GET call. key is the API key.

...

Curl options passed to HttpClient

Value

data frame if type="data.frame" (default) and the colnames if type="colnames"

Details

The XPort tables have a few columns that do not appear in the Excel files that one can download from StreamNet: "species", "publish", "num", "hli", "agency", "esudps", "hli_id". "esudps" is a slight variant on "esu_dps" and is removed. "num" is a sort flag and is removed. "hli_id" is an internal reference id and is removed. "publish" will always be Yes but is left in. The other columns are left in. The colnames are re-sorted into the order found in the downloaded Excel files with the extra columns added to the end.

The table columns are sorted into the order that appears in CAP Fish HLIs Tabular Query. If you want to see the original columns in the original order, use cols=1:50, say, to see the first 50 columns in the original order.

If tabletype="base" is used, the base tables without the added metadata are returned. The data are the same just missing the extra metadata.

If you want to see only the column names use type="colnames.

Examples

# return NMFS_PopID of second record
# Note the part after $ is case sensitive
id <- rcax_hli("NOSA", qlist=list(limit=2))$nmfs_popid[2]

a <- rcax_hli("NOSA",
         flist=list(nmfs_popid=id),
         cols=c("nmfs_popid", "spawningyear", "tsaej", "nosaej")
         )
head(a)
#>   nmfs_popid spawningyear tsaej nosaej
#> 1        185         1990   434     19
#> 2        185         1991    39      5
#> 3        185         1992   143     11
#> 4        185         1993   364     13
#> 5        185         1994  1554     91
#> 6        185         1995  1325    105

# First 3 columns
rcax_hli("NOSA", qlist=list(limit=3))[,1:3]
#>       commonname    run    recoverydomain
#> 1 Chinook salmon Spring Interior Columbia
#> 2      Steelhead Summer Interior Columbia
#> 3    Coho salmon   Fall      Oregon Coast

# to print the first column names and definitions
head(rcax_hli("NOSA", type="colnames"))
#>                        name
#> 107               age10prop
#> 41      age10proplowerlimit
#> 24      age10propupperlimit
#> 108           age11plusprop
#> 109 age11plusproplowerlimit
#> 62  age11pluspropupperlimit
#>                                                                            definition
#> 107          The proportion of natural origin fish that were age 10 (brood year +10).
#> 41                              Lower limit of the confidence interval for Age10Prop.
#> 24                              Upper limit of the confidence interval for Age10Prop.
#> 108 The proportion of natural origin fish that were age 11 (brood year +11) or older.
#> 109                         Lower limit of the confidence interval for Age11PlusProp.
#> 62                          Upper limit of the confidence interval for Age11PlusProp.