1 | stairstepn(data, direction = "hv", yvars = "y")
|
data |
|
direction |
|
yvars |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (data, direction = "hv", yvars = "y")
{
direction <- match.arg(direction, c("hv", "vh"))
data <- as.data.frame(data)[order(data$x), ]
n <- nrow(data)
if (direction == "vh") {
xs <- rep(1:n, each = 2)[-2 * n]
ys <- c(1, rep(2:n, each = 2))
}
else {
ys <- rep(1:n, each = 2)[-2 * n]
xs <- c(1, rep(2:n, each = 2))
}
data.frame(x = data$x[xs], data[ys, yvars, drop = FALSE],
data[xs, setdiff(names(data), c("x", yvars)), drop = FALSE])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.