# NOT RUN {
library("ggplot2")
set.seed(100)
dataset = data.frame(x = sort(runif(1e2)),
y = c(rnorm(1e2/2), rnorm(1e2/2, mean = 4)),
w = sample(1:3, 1e2, replace = TRUE)
)
# plot isotonic regression line
ggplot(dataset, aes(x = x, y = y)) +
geom_point() +
stat_isotonic()
# plot weighted isotonic regression line along with facets
ggplot(dataset, aes(x = x, y = y)) +
geom_point() +
stat_isotonic(aes(w = w), color = 'red', size = 1.5, show.legend = FALSE) +
facet_wrap(w ~ .)
# }
Run the code above in your browser using DataLab