The R Project SVN R

Rev

Rev 61160 | Rev 76674 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 61160 Rev 61168
Line 42... Line 42...
42
\examples{
42
\examples{
43
require(graphics)
43
require(graphics)
44
 
44
 
45
y <- ys <- (-20:20)^2
45
y <- ys <- (-20:20)^2
46
y [c(1,10,21,41)] <-  c(100, 30, 400, 470)
46
y [c(1,10,21,41)] <-  c(100, 30, 400, 470)
47
s7k <- runmed(y,7, endrule = "keep")
47
s7k <- runmed(y, 7, endrule = "keep")
48
s7. <- runmed(y,7, endrule = "const")
48
s7. <- runmed(y, 7, endrule = "const")
49
s7m <- runmed(y,7)
49
s7m <- runmed(y, 7)
50
col3 <- c("midnightblue","blue","steelblue")
50
col3 <- c("midnightblue","blue","steelblue")
51
plot(y, main = "Running Medians -- runmed(*, k=7, end.rule = X)")
51
plot(y, main = "Running Medians -- runmed(*, k=7, end.rule = X)")
52
lines(ys, col = "light gray")
52
lines(ys, col = "light gray")
53
matlines(cbind(s7k,s7.,s7m), lwd= 1.5, lty = 1, col = col3)
53
matlines(cbind(s7k, s7.,s7m), lwd = 1.5, lty = 1, col = col3)
54
legend(1,470, paste("endrule", c("keep","constant","median"), sep = " = "),
54
legend(1, 470, paste("endrule", c("keep","constant","median"), sep = " = "),
55
       col = col3, lwd = 1.5, lty = 1)
55
       col = col3, lwd = 1.5, lty = 1)
56
 
56
 
57
stopifnot(identical(s7m, smoothEnds(s7k, 7)))
57
stopifnot(identical(s7m, smoothEnds(s7k, 7)))
58
}
58
}
59
\keyword{smooth}
59
\keyword{smooth}