The R Project SVN R

Rev

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

Rev 61160 Rev 61168
Line 41... Line 41...
41
  \item{\dots}{potentially further arguments (required by the generic).}
41
  \item{\dots}{potentially further arguments (required by the generic).}
42
}
42
}
43
\description{
43
\description{
44
  Given the vectors \eqn{(x_1, \ldots, x_n)}{(x[1], \dots, x[n])} and
44
  Given the vectors \eqn{(x_1, \ldots, x_n)}{(x[1], \dots, x[n])} and
45
  \eqn{(y_0,y_1,\ldots, y_n)}{(y[0], y[1], \dots, y[n])} (one value
45
  \eqn{(y_0,y_1,\ldots, y_n)}{(y[0], y[1], \dots, y[n])} (one value
46
  more!), \code{stepfun(x,y,\dots)} returns an interpolating
46
  more!), \code{stepfun(x, y, \dots)} returns an interpolating
47
  \sQuote{step} function, say \code{fn}. I.e., \eqn{fn(t) =
47
  \sQuote{step} function, say \code{fn}. I.e., \eqn{fn(t) =
48
    c}\eqn{_i}{[i]} (constant) for \eqn{t \in (x_i, x_{i+1})}{t in (
48
    c}\eqn{_i}{[i]} (constant) for \eqn{t \in (x_i, x_{i+1})}{t in (
49
    x[i], x[i+1])} and at the abscissa values, if (by default)
49
    x[i], x[i+1])} and at the abscissa values, if (by default)
50
  \code{right = FALSE}, \eqn{fn(x_i) = y_i}{fn(x[i]) = y[i]} and for
50
  \code{right = FALSE}, \eqn{fn(x_i) = y_i}{fn(x[i]) = y[i]} and for
51
  \code{right = TRUE}, \eqn{fn(x_i) = y_{i-1}}{fn(x[i]) = y[i-1]}, for
51
  \code{right = TRUE}, \eqn{fn(x_i) = y_{i-1}}{fn(x[i]) = y[i-1]}, for
Line 89... Line 89...
89
  step functions.
89
  step functions.
90
 
90
 
91
  \code{\link{approxfun}} and \code{\link{splinefun}}.
91
  \code{\link{approxfun}} and \code{\link{splinefun}}.
92
}
92
}
93
\examples{
93
\examples{
94
y0 <- c(1.,2.,4.,3.)
94
y0 <- c(1., 2., 4., 3.)
95
sfun0  <- stepfun(1:3, y0, f = 0)
95
sfun0  <- stepfun(1:3, y0, f = 0)
96
sfun.2 <- stepfun(1:3, y0, f = .2)
96
sfun.2 <- stepfun(1:3, y0, f = 0.2)
97
sfun1  <- stepfun(1:3, y0, f = 1)
97
sfun1  <- stepfun(1:3, y0, f = 1)
98
sfun1c <- stepfun(1:3, y0, right = TRUE) # hence f=1
98
sfun1c <- stepfun(1:3, y0, right = TRUE) # hence f=1
99
sfun0
99
sfun0
100
summary(sfun0)
100
summary(sfun0)
101
summary(sfun.2)
101
summary(sfun.2)
Line 106... Line 106...
106
 
106
 
107
x0 <- seq(0.5, 3.5, by = 0.25)
107
x0 <- seq(0.5, 3.5, by = 0.25)
108
rbind(x = x0, f.f0 = sfun0(x0), f.f02 = sfun.2(x0),
108
rbind(x = x0, f.f0 = sfun0(x0), f.f02 = sfun.2(x0),
109
      f.f1 = sfun1(x0), f.f1c = sfun1c(x0))
109
      f.f1 = sfun1(x0), f.f1c = sfun1c(x0))
110
## Identities :
110
## Identities :
111
stopifnot(identical(y0[-1], sfun0 (1:3)),# right = FALSE
111
stopifnot(identical(y0[-1], sfun0 (1:3)), # right = FALSE
112
          identical(y0[-4], sfun1c(1:3)))# right = TRUE
112
          identical(y0[-4], sfun1c(1:3))) # right = TRUE
113
}
113
}
114
\keyword{dplot}
114
\keyword{dplot}