'undefined columns selected' in empty result in readNWISstat
I think this issue just popped up in the last few weeks, consistent with the warning that "the NWIS data service feeding this function is in BETA":
> dataRetrieval::readNWISstat('295827090052800', parameterCd='00060', startDate='2007', statReportType='annual', statType='mean')
Please be aware the NWIS data service feeding this function is in BETA.
Data formatting could be changed at any time, and is not guaranteed
Error in `[.data.frame`(data, , c("agency_cd", "site_no")) :
undefined columns selected
many other sites work just fine, e.g.,
> dataRetrieval::readNWISstat('01658000', parameterCd='00060', startDate='2007', statReportType='annual', statType='mean')
Please be aware the NWIS data service feeding this function is in BETA.
Data formatting could be changed at any time, and is not guaranteed
agency_cd site_no parameter_cd ts_id loc_web_ds year_nu mean_va
1 USGS 01658000 00060 68696 <NA> 2007 50.2
2 USGS 01658000 00060 68696 <NA> 2008 57.8
3 USGS 01658000 00060 68696 <NA> 2009 77.4
4 USGS 01658000 00060 68696 <NA> 2010 50.0
5 USGS 01658000 00060 68696 <NA> 2011 75.9
6 USGS 01658000 00060 68696 <NA> 2012 25.1
7 USGS 01658000 00060 68696 <NA> 2013 51.8
8 USGS 01658000 00060 68696 <NA> 2014 66.7
9 USGS 01658000 00060 68696 <NA> 2015 44.2
10 USGS 01658000 00060 68696 <NA> 2016 40.2
I think the error is probably occurring when no rows are returned.