USGS-R / rloadest

USGS water science R functions for LOAD ESTimation of constituents in rivers and streams.
Other
20 stars 19 forks source link

predLoad error with flow data #17

Closed bhallUSGS closed 7 years ago

bhallUSGS commented 7 years ago

When running the predLoad function I get the error below. This worked in a previous version a few months ago but I am getting this new error and don't know how to correct it. The newdata file is has only 2 columns (Date and Flow) that were pulled from NWISweb.

FP.N <- predLoad(fit = FP.N.lr, newdata = FP.Flow, load.units = "kg", by = "day", allow.incomplete = T, print = T) Error in aggregate.data.frame(newdata, list(time.step = gps), mean) : arguments must have same length

lperreau-usgs commented 7 years ago

I ran into this problem last week - for me, the resolution was to go back to the newdata file and fix it so that every single day had the same number of observations (i.e., I was using unit value data, so every day needed to have the same number of punches, 96, to be complete). It does appear to be a new issue - the loads calculated last year didn't snag on this, despite similarly uneven data.

ldecicco-USGS commented 7 years ago

Could one of you provide a reproducible example? Especially if it's all just NWIS data, that should be something we can re-create. Nothing has changed with rloadest in a long time. However, dependencies of rloadest can change at anytime...which could cause un-intended consequences.

lschenk1 commented 7 years ago

Hi there. I know it's been awhile since this string, but I've encountered the same issue re: Error in aggregate.data.frame. Has there been a resolution to this?

bhallUSGS commented 7 years ago

To close this issue, here is a reply that I received via email that solved the problem for me and lschenk1:

_I took a look at your script, the issue seems to be that predLoad is expecting the column names in newdata to equivalent to what was set in the selBestModel call, but they are not ("Date" and "Flow" vs "sample_dt" and "Q"). The "arguments are different lengths" error happens because the function is looking for a nonexistent column, and then starts to work with a NULL instead since it can't find the column._