From d68d47f834ef14fcda4000a6651720e05c51b436 Mon Sep 17 00:00:00 2001
From: Laura DeCicco <ldecicco@usgs.gov>
Date: Wed, 25 Nov 2015 14:14:09 -0600
Subject: [PATCH] Updated renameNWISColumns to work with rdb output.

---
 NEWS                     | 7 +++++++
 R/renameColumns.R        | 6 +++++-
 man/renameNWISColumns.Rd | 4 ++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index b33e5666..2fa474d0 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+dataRetrieval 2.4.0
+==========
+* Package readr now used for tab delimited parsing
+* readr functions used to determine column types. Mostly, this produces the same results. 
+* In the case where there is text in a numeric column (specified by the RDB header), these now remain characters (previously was converted to numeric)
+* 
+
 dataRetrieval 2.3.0
 ===========
 * Converted all Water Quality Portal queries to sorted=no to greatly improve retrieval times
diff --git a/R/renameColumns.R b/R/renameColumns.R
index 505b640e..0af8bcbc 100644
--- a/R/renameColumns.R
+++ b/R/renameColumns.R
@@ -45,6 +45,10 @@
 #' url2 <- constructNWISURL(siteWithTwo, "00060",startDate,endDate,'dv')
 #' twoResults <- importWaterML1(url2,TRUE)
 #' twoResults <- renameNWISColumns(twoResults)
+#' url2RDB <- constructNWISURL(siteWithTwo,"00060",
+#'          startDate,endDate,"dv",format="tsv")
+#' rdbResults <- importRDB1(url2RDB)
+#' rdbResults <- renameNWISColumns(rdbResults) 
 #' }
 renameNWISColumns <- function(rawData, p00010="Wtemp", p00045="Precip",
                           p00060="Flow", p00065="GH", p00095="SpecCond", p00300="DO",
@@ -78,7 +82,7 @@ renameNWISColumns <- function(rawData, p00010="Wtemp", p00045="Precip",
   Conv$s00023<- "HiLoTide"
   Conv$s00024<- "LoLoTide"
 
-  dataColumns <- grep("X_", Cnames)
+  dataColumns <- c(grep("X_", Cnames),grep("X\\d{2}", Cnames))
   
   for (i in dataColumns){
     chunks <- strsplit(Cnames[i], "_")[[1]]
diff --git a/man/renameNWISColumns.Rd b/man/renameNWISColumns.Rd
index 84c6b277..e877e042 100644
--- a/man/renameNWISColumns.Rd
+++ b/man/renameNWISColumns.Rd
@@ -68,6 +68,10 @@ endDate <- "2012-10-01"
 url2 <- constructNWISURL(siteWithTwo, "00060",startDate,endDate,'dv')
 twoResults <- importWaterML1(url2,TRUE)
 twoResults <- renameNWISColumns(twoResults)
+url2RDB <- constructNWISURL(siteWithTwo,"00060",
+         startDate,endDate,"dv",format="tsv")
+rdbResults <- importRDB1(url2RDB)
+rdbResults <- renameNWISColumns(rdbResults) 
 }
 }
 \seealso{
-- 
GitLab