Closed brownag closed 3 years ago
I think that I have a simple solution, using data.table::rbindlist
. Seems to work, please test filter_geochem
. I'm not sure, but it seems to work as well.
I think the rbindlist
is a partial solution, thanks.
From what I can see this only NA-fills in the profile labsampnum
s that have no data with NA
-- which is good, but the same is not done for profiles that have only some of their horizons measured (very common for geochemical data).
I think I would prefer my latter option here that the various data.frame objects returned with returnGeochemicalData =TRUE have all of the labsampnum from the related SPC, which means cross referencing the contents of the combined SPC to each of the result tables. I dont think any of these changes should affect filter_geochem
OK, I see. Two options here:
labsampnum
(LEFT JOIN) even when all of the data might be NA. That would greatly simplify post-processing in R, but introduce a lot of "newness" in the API. Also, it adds a lot of bloat to the data being pushed around the wire.I'm going to try option 2 first (0-length data.frame
with labsampnum
column), as I have a major re-write of the API on my TODO list for next month.
If a particular pedlabsampnum has NULL geochemical data, and the fetchKSSL
pedlabsampnum
interface is used dummy records with badlabsampnum
("FALSE"
) are included in the result.Traces back to this https://github.com/ncss-tech/soilDB/blob/6e1750b1ce9506d617e8e84a581dd946a642d80c/R/fetchKSSL.R#L386-L389 which will "fill" in data (FALSE and 0) when
rbind
ing the 2 row data.frame from first pedon witdata with the 1x1 logical matrix that comes out of the second pedon without dataI think these records should be filtered out, or alternately some sort of NA-filled record should be provided for each labsampnum.