R/detrend.R

Defines functions `detrend`

`detrend` <-
function(x)
  {
    ##  remove linear trend from a time series
   
    n = length(x)
    
    t = seq(1,n)

    r = lm(x ~ t)
    b = r$coefficients[1]
    m = r$coefficients[2]
    
    newf = x - (m*t+b)
    
    return(newf)
}

Try the RSEIS package in your browser

Any scripts or data that you put into this service are public.

RSEIS documentation built on Aug. 19, 2023, 5:07 p.m.