## ----runlm-case1, fig.path='2014-02-11-', dpi=100------------------------ library(oce) x <- 1:100 y <- 1 + x/100 + sin(x/5) yn <- y + rnorm(100, sd=0.1) L <- 4 calc <- runlm(x, y, L=L, deriv=0) plot(x, y, type='l', lwd=7, col='gray') points(x, yn, pch=20, col='blue') lines(x, calc, lwd=2, col='red') ## ----runlm-case2, fig.path='2014-02-11-', dpi=100------------------------ data(ctd) plot(ctd, which="N2") rho <- swRho(ctd) z <- swZ(ctd) zz <- seq(min(z), max(z), 0.1) N2 <- -9.8 / mean(rho) * runlm(z, rho, zz, deriv=1) lines(N2, -zz, col='red') legend("bottomright", lwd=2, bg="white", col=c("black", "red"), legend=c("swN2()", "using runlm()"))