Skip to content

Commit

Permalink
Make it examples take less time (than forever)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Jun 29, 2015
1 parent fe7330a commit 9cce240
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions R/h.r
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@
#' needed (i.e. the estimate is on the lower bounds), a warning is thrown.
#' @export
#' @examples
#' \donttest{
#' x <- rchallenge(1e4)
#' xsum <- condense(bin(x, 1 / 10))
#' h <- best_h(xsum, control = list(trace = 1, REPORT = 1))
#' h <- best_h(xsum)
#' h <- best_h(xsum, control = list(trace = 3, REPORT = 1))
#'
#' if (require("ggplot2")) {
#' autoplot(xsum)
#' autoplot(smooth(xsum, h))
#' }
#' }
best_h <- function(x, h_init = NULL, ..., tol = 1e-2, control = list()) {
stopifnot(is.condensed(x))

Expand Down
2 changes: 2 additions & 0 deletions R/rmse.r
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#' @family bandwidth estimation functions
#' @export
#' @examples
#' \donttest{
#' set.seed(1014)
#' # 1d -----------------------------
#' x <- rchallenge(1e4)
Expand All @@ -33,6 +34,7 @@
#' if (require("ggplot2")) {
#' qplot(x, y, data = cvs, size = err)
#' }
#' }
rmse_cvs <- function(x, hs = h_grid(x), ...) {
rmse_1 <- function(i) {
rmse_cv(x, as.numeric(hs[i, ]), ...)
Expand Down
5 changes: 3 additions & 2 deletions man/best_h.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ of bandwidth makes little difference visually, and we're unlikely to have
sufficient data to make a statistically significant choice anyway.
}
\examples{
\donttest{
x <- rchallenge(1e4)
xsum <- condense(bin(x, 1 / 10))
h <- best_h(xsum, control = list(trace = 1, REPORT = 1))
h <- best_h(xsum)
h <- best_h(xsum, control = list(trace = 3, REPORT = 1))

if (require("ggplot2")) {
autoplot(xsum)
autoplot(smooth(xsum, h))
}
}
}
\seealso{
Other bandwidth estimation functions: \code{\link{h_grid}};
\code{\link{rmse_cv}}, \code{\link{rmse_cvs}}
Expand Down
2 changes: 2 additions & 0 deletions man/rmse_cvs.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ bandwidths, \code{rmse_cvs} computes for a multiple vectors of bandwidths,
stored as a data frame.
}
\examples{
\donttest{
set.seed(1014)
# 1d -----------------------------
x <- rchallenge(1e4)
Expand All @@ -47,6 +48,7 @@ if (require("ggplot2")) {
qplot(x, y, data = cvs, size = err)
}
}
}
\seealso{
Other bandwidth estimation functions: \code{\link{best_h}};
\code{\link{h_grid}}
Expand Down

0 comments on commit 9cce240

Please sign in to comment.