X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=statistics%2Ffunctions.r;h=e02ee67d27ac25db37fa98ed322b766886ab8798;hb=a00628d4ae71b919c03761d139de3087e7d2a413;hp=bc6b8d49311d94adaecd53a4024ced223a26e9a8;hpb=a043462186ca0db241c1b52b6660ee39dcbceb3e;p=monitor.git diff --git a/statistics/functions.r b/statistics/functions.r index bc6b8d4..e02ee67 100644 --- a/statistics/functions.r +++ b/statistics/functions.r @@ -397,10 +397,15 @@ add_timestamp <- function (t) return (t); } -abline_at_date <- function (date, col='black', lty=1, format="%Y-%m-%d") +abline_at_date <- function (date, col='black', lty=1, format="%Y-%m-%d", height=0) { ts <-unclass(as.POSIXct(date, format=format, origin="1970-01-01"))[1] - abline(v=ts, col=col, lty=lty) + if ( height == 0 ) + { + abline(v=ts, col=col, lty=lty) + } else { + lines(c(ts,ts),c(0,height), col=col, lty=lty) + } return (ts); } @@ -409,3 +414,9 @@ tstamp <- function (date, format="%Y-%m-%d") ts <- unclass(as.POSIXct(date, format=format, origin="1970-01-01"))[1] return (ts) } + +lowess_smooth <- function (x, y, delta=(60*60*24), f=0.02) +{ + a<-lowess(x, y, delta=delta, f=f) + return (a); +}