Closed katherinejchase closed 4 years ago
Is the "Milk_dv_data" coming from a dataRetrieval call? If so, could you paste that code so that the issue is reproducible? (ie... so I can get the error on my computer too)
Here is the code. I think the error has something to do with dv=0. When I replace 0 with 0.1 the error doesn't occur.
site <- "06155030"
Milk <- readNWISdv(site = site, parameterCd = "00060") Milk_dv_data <- renameNWISColumns(Milk)
Milk_dur <- with(Milk_dv_data, tapply(Flow, baseDay(Date, FALSE, year = "water"), FUN = quantile, probs = c(0, .1, .25, .75, .9, 1), na.rm = TRUE))
Milk_dur <- do.call(rbind, Milk_dur)
setGD("Milk") AA.lo <- setLayout(explanation=list(bottom=1.5)) setGraph(1, AA.lo)
AA.pl <- with(Milk_dv_data, timePlot(Date, Flow, Plot = list(what = "none"), ytitle="Streamflow, in cubic feet per second", yaxis.log=TRUE, xaxis.range=as.Date(c("2018-10-01", "2019-09-30"))))
So it looks like you are doing a log scale, and the smwr function can't handle taking the log of 0. Some packages like ggplot2 will remove that data and spit out a message, but I don't think it's unreasonable to have an error when trying to do a log scale with zero's. I think you could choose between setting your 0's to something very small (like you mentioned), or removing the rows with 0 flow. Not sure if a linear scale is on the table for your application, but that might work too.
Thank you for looking into this! The error message itself is hard to relate to the data including 0's. I appreciate your help.
I have been following the duration plot demo, and successfully plotting duration hydrographs for several gages. However for certain sites in my current batch of gages, I get this message after the
Create the empty graph lines:
AA.pl <- with(Milk_dv_data, timePlot(Date, Flow, Plot = list(what = "none"), ytitle="Streamflow, in cubic feet per second", yaxis.log=TRUE, xaxis.range=as.Date(c("2018-10-01", "2019-09-30"))))
Error in if (labels.per.cycle > 8) { : missing value where TRUE/FALSE needed In addition: Warning message: In logPretty(drange, hard = hard, labels = axis.labels, ...) : NAs introduced by coercion to integer range