Description Usage Arguments Value Examples
Convert raw predictions to final predictions, possibly including a switch between flux and conc. If there is a switch, the units will be converted according to the metadata.
1 2 3 |
preds |
raw prediction values |
from.format |
character in
|
to.format |
character indicating whether the returned value should be a flux or a concentration. |
newdata |
a data.frame with nrow() == length(preds) and containing any
columns (named as in |
metadata |
An object of class |
lin.or.log |
character. Either "linear" or "log" to say whether the predictions
should be converted to log space or not. If converted to log space, a bias correction
will be applied, see |
attach.units |
logical. Attach the units to the returned value? |
converted predictions (in the format/units specified by to.format and metadata)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | obs <- transform(data.frame(MyConc=1:10, MyFlow=rep(10,10)),
MyFlux=MyConc*MyFlow*rloadest::loadConvFactor("cms", "mg/l", "kg") )
md <- metadata(constituent="MyConc", flow="MyFlow",
load.rate="MyFlux", dates="none", flow.units="m^3 s^-1", conc.units="mg L^-1",
load.units="kg", load.rate.units="kg/d", site.name='My River', custom=NULL)
all.equal(obs$MyFlux, formatPreds(
preds=obs$MyConc, from.format="conc", to.format="flux", newdata=obs, metadata=md))
## Not run:
# these examples take too long to build regularly
all.equal(obs$MyFlux, formatPreds(
preds=obs$MyConc*obs$MyFlow, from.format="conc*flow", to.format="flux",
newdata=obs, metadata=md))
all.equal(obs$MyConc, formatPreds(
preds=obs$MyFlux, from.format="flux", to.format="conc", newdata=obs, metadata=md))
all.equal(unitted::u(obs$MyConc, "mg L^-1"), formatPreds(
preds=obs$MyFlux, from.format="flux", to.format="conc", newdata=obs, metadata=md,
attach.units=TRUE))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.