DOI-USGS / dataRetrieval

This R package is designed to obtain USGS or EPA water quality sample data, streamflow data, and metadata directly from web services.
https://doi-usgs.github.io/dataRetrieval/
Other
256 stars 85 forks source link

Allow `pcode_to_name` to modify duplicate pcodes without producing a warning #703

Closed jpadilla-spu closed 2 months ago

jpadilla-spu commented 2 months ago

Overview

This PR fixes the false warnings described in #702

Major changes

No major edits! I added one quick fix to the pcode_to_name function

Verification

After using devtools to re-install the package you should see the following:

Script:

library(dataRetrieval)

pcodes <- c("00060", "00065", "00065", "1234")

# works as expected
pcode_to_name(pcodes[1:2])$characteristicname

# works as expected - with the fix
pcode_to_name(pcodes[1:3])$characteristicname

# real errors
pcode_to_name(pcodes)$characteristicname
pcode_to_name(pcodes[3:4])$characteristicname

Results:

> # works as expected
> pcode_to_name(pcodes[1:2])$characteristicname
[1] "Stream flow"  "Height, gage"
> # works as expected - with the fix
> pcode_to_name(pcodes[1:3])$characteristicname
[1] "Stream flow"  "Height, gage" "Height, gage"
> # real errors
> pcode_to_name(pcodes)$characteristicname
[1] "Stream flow"  "Height, gage" "Height, gage" NA            
Warning message:
In pcode_to_name(pcodes) :
  The following pCodes seem mistyped, and no information was returned: 1234
> pcode_to_name(pcodes[3:4])$characteristicname
[1] "Height, gage" NA            
Warning message:
In pcode_to_name(pcodes[3:4]) :
  The following pCodes seem mistyped, and no information was returned: 1234

closes #702

ldecicco-USGS commented 2 months ago

Thanks @jpadilla-spu !