header_tag.html

Skip to contents

Rename columns coming back from NWIS data retrievals. Daily and unit value columns have names derived from their data descriptor, parameter, and statistic codes. This function reads information from the header and the arguments in the call to to rename those columns.

Usage

renameNWISColumns(
  rawData,
  p00010 = "Wtemp",
  p00045 = "Precip",
  p00060 = "Flow",
  p00065 = "GH",
  p00095 = "SpecCond",
  p00300 = "DO",
  p00400 = "pH",
  p62611 = "GWL",
  p63680 = "Turb",
  p72019 = "WLBLS",
  ...
)

Arguments

rawData

the daily- or unit-values datset retrieved from NWISweb.

p00010

the base name for parameter code 00010.

p00045

the base name for parameter code 00045.

p00060

the base name for parameter code 00060.

p00065

the base name for parameter code 00065.

p00095

the base name for parameter code 00095.

p00300

the base name for parameter code 00300.

p00400

the base name for parameter code 00400.

p62611

the base name for parameter code 62611.

p63680

the base name for parameter code 63680.

p72019

the base name for parameter code 72019.

...

named arguments for the base name for any other parameter code. The form of the name must be like pXXXXX, where XXXXX is the parameter code.

Value

A dataset like data with selected columns renamed.

Note

The following statistics codes are converted by renameNWISColumns.

00000

Instantaneous Value, suffix: Inst

00001

Maximum value, suffix: Max

00002

Minimum value, suffix: Min

00003

Mean value, no suffix

00006

Sum of values, suffix: Sum

00007

Modal value, suffix: Mode

00008

Median value, suffix: Median

00012

Equivalent mean value, suffix: EqMean

00021

Tidal high-high value, suffix: HiHiTide

00022

Tidal low-high value, suffix: LoHiTide

00023

Tidal high-low value, suffix: HiLoTide

00024

Tidal low-low value, suffix: LoLoTide

Examples

siteWithTwo <- "01480015"
startDate <- "2012-09-01"
endDate <- "2012-10-01"
# \donttest{
twoResults <- readNWISdv(siteWithTwo, "00060", startDate, endDate)
#> GET:https://waterservices.usgs.gov/nwis/dv/?site=01480015&format=waterml%2C1.1&ParameterCd=00060&StatCd=00003&startDT=2012-09-01&endDT=2012-10-01
names(twoResults)
#> [1] "agency_cd"        "site_no"          "Date"             "X_00060_00003"   
#> [5] "X_00060_00003_cd"
renamedCols <- renameNWISColumns(twoResults)
names(renamedCols)
#> [1] "agency_cd" "site_no"   "Date"      "Flow"      "Flow_cd"  
# Custom names:
newNames <- renameNWISColumns(twoResults, p00060 = "Discharge")
names(newNames)
#> [1] "agency_cd"    "site_no"      "Date"         "Discharge"    "Discharge_cd"
# }