Learn R Programming

stepR (version 2.1-10)

stepblock: Step function

Description

Constructs an object containing a step function sampled over finitely many values.

Usage

stepblock(value, leftEnd = c(1, rightEnd[-length(rightEnd)] + 1), rightEnd, x0 = 0)
# S3 method for stepblock
[(x, i, j, drop = if(missing(i)) TRUE else if(missing(j)) FALSE else length(j) == 1, ...)
# S3 method for stepblock
print(x, ...)
# S3 method for stepblock
plot(x, type = "c", xlab = "x", ylab = "y", main = "Step function", sub = NULL, ...)
# S3 method for stepblock
lines(x, type = "c", ...)

Value

For stepblock an object of class stepblock, i.e. a data.frame with columns value, leftEnd and rightEnd and attribute x0.

Arguments

value

a numeric vector containing the fitted values for each block; its length gives the number of blocks

leftEnd

a numeric vector of the same length as value containing the left end of each block

rightEnd

a numeric vector of the same length as value containing the right end of each block

x0

a single numeric giving the last unobserved sample point directly before sampling started, i.e. before leftEnd[1]

x

the object

i, j, drop

see [.data.frame

type

"c" to plot jumps in the middle between the end of the previous block (or x0) and the beginning of the following block; "e" to jump at the end of the previous block; "b" to jump at the beginning of the following block; capital letters also plot points

xlab, ylab, main, sub

see plot.default

...

for generic methods only

See Also

Examples

Run this code
# step function consisting of 3 blocks: 1 on (0, 3]; 2 on (3, 6], 0 on (6, 8]
# sampled on the integers 1:10
f <- stepblock(value = c(1, 2, 0), rightEnd = c(3, 6, 8))
f
# show different plot types
plot(f, type = "C")
lines(f, type = "E", lty = 2, col = "red")
lines(f, type = "B", lty = 3, col = "blue")
legend("bottomleft", legend = c("C", "E", "B"), lty = 1:3, col = c("black", "red", "blue"))

Run the code above in your browser using DataLab