stfl_plot_add_regional_fit: Add the regional fit to an existing trend plot

Description Usage Arguments Value Examples

View source: R/stfl_plot_add_regional_fit.R

Description

Add the regional fit to an existing trend plot

Usage

1
2
3
4
5
stfl_plot_add_regional_fit(
  plot,
  regional.fit,
  plot.fit = c("LMrob", "LM", "MK")[1]
)

Arguments

plot

An existing plotly objects to which the regional fit will be added

regional.fit

A list object containing the results of the region fit. See the help page for stfl_trend_regional() for details on this object

plot.fit

Which trend lines should be added to the plots. Possible values are one or more of

  • LM: Ordinary regression using the lm() function

  • MK: Mann-Kendall estimates using Sen estimator

  • LMrob: Robust linear regression fit using the lmrob() function from the robustbase package

If you try and plot a method that was not computed, a warning message is printed and the request is ignored.

Value

Plotly object is returned with the regional fit(s) added to the plot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# needs the HYDAT package installed
station.id <- c("08NM053","08NM116")
data <- stfl_get_annual_stat(station.id, Statistic=c("MEAN"))
temp <- stfl_trend_kstn_kstat(data, log.Y=TRUE)
myplot <- stfl_plot_trends(temp, plot.fit=c("MK","LM","LMrob"))
myplot
data$REGION <- "AnyOldRegion"
mystation.weights <- data.frame(STATION_NUMBER=station.id, WEIGHT=c(2,1))
regional.fit <- stfl_trend_regional(data, mystation.weights, log.Y=TRUE)
stfl_plot_add_regional_fit(myplot,  regional.fit[[1]])

## End(Not run)

bcgov/StreamFlowTrend documentation built on Dec. 19, 2021, 7:38 a.m.