#' run-down correction methods
#'
#'
#' @param x, usually the time values of an i/t plot
#' @param y, usually the results of a cursor method, as they appear in an i/T plot
#' @seealso to be used with \link{plotIt}
#'
#' @name rundowncorrection
NULL
#' @describeIn rundowncorrection
#' usues an lm fit over the region defined by 'subset' for rundown correction
#' @param subset region of the i/t plot to be used for fitting and/or anchoring of run down correction
#' @export
rundown_lm<-function(x,y, subset,...){
m=lm(y~x, subset=subset)
y_<-predict(m, as.data.frame(x))
lines(y_~x)
points(x[subset], y[subset], col="red", pch=13 )
y_corr=y[subset[1]]*y/y_
points(x,y_corr, col="blue")
y_corr
}
#' @describeIn rundowncorrection
#' usues a fixed slope defined by 'slope', and anchored at 'subset[1]', for rundown correction
#' @param slope the slope of a linear rundown correction
#' @export
rundown_fix<-function(x,y, subset, slope,...){
plot(x,y, col="grey80", ...)
y_<-y+((1:length(y))*slope)
lines(y_~x)
points(x[subset], y[subset], col="red", pch=13 )
y_corr=y_
points(x,y_corr, col="blue")
y_corr
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.