Skip to content

Commit

Permalink
begin separating examples per #78
Browse files Browse the repository at this point in the history
  • Loading branch information
corybrunson committed Jan 27, 2025
1 parent 7c28d14 commit eab9675
Show file tree
Hide file tree
Showing 17 changed files with 177 additions and 128 deletions.
3 changes: 1 addition & 2 deletions R/stat-bagplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
#' @param fraction Fraction of the data to include in the bag.
#' @param coef Scale factor of the fence relative to the bag.
#' @family stat layers
#' @example inst/examples/ex-stat-bagplot-judges.r
#' @example inst/examples/ex-stat-bagplot-iris.r
#' @example inst/examples/ex-stat-bagplot.r
#' @export
stat_bagplot <- function(
mapping = NULL, data = NULL, geom = "bagplot", position = "identity",
Expand Down
2 changes: 1 addition & 1 deletion R/stat-center.r
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @template param-stat
#' @template return-layer
#' @family stat layers
#' @example inst/examples/ex-stat-center-iris.r
#' @example inst/examples/ex-stat-center.r
#' @export
stat_center <- function(
mapping = NULL, data = NULL, geom = "point", position = "identity",
Expand Down
3 changes: 1 addition & 2 deletions R/stat-chull.r
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
#' @template param-stat
#' @template return-layer
#' @family stat layers
#' @example inst/examples/ex-stat-chull-haireye.r
#' @example inst/examples/ex-stat-peel-judges.r
#' @example inst/examples/ex-stat-chull.r
#' @export
stat_chull <- function(
mapping = NULL, data = NULL, geom = "polygon", position = "identity",
Expand Down
7 changes: 6 additions & 1 deletion R/zzz-biplot-stats.r
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
#' @inheritParams stat_rule
#' @inheritParams stat_scale
#' @inheritParams stat_spantree
#' @example inst/examples/ex-stat-ellipse-iris.r
#' @example inst/examples/ex-stat-bagplot-ord-iris.r
#' @example inst/examples/ex-stat-bagplot-ord-judges.r
#' @example inst/examples/ex-stat-center-ord-iris.r
#' @example inst/examples/ex-stat-chull-ord-haireye.r
#' @example inst/examples/ex-stat-ellipse-ord-iris.r
#' @example inst/examples/ex-stat-peel-ord-judges.r
NULL

#' @rdname ordr-ggproto
Expand Down
27 changes: 15 additions & 12 deletions build-pre/build-layers.r
Original file line number Diff line number Diff line change
Expand Up @@ -324,15 +324,20 @@ done_protos <- unlist(lapply(layer_files, function(f) {
## 3. Run generators on manual and found lists of layers.
Sys.sleep(.5)

# find layer-specific examples
ex_files <- list.files(here::here("inst/examples/"), "(stat|geom)-.*\\.(r|R)")
# restrict to examples without home documentation files
ex_match <- sapply(
str_replace_all(str_remove(orig_layers, "^(.*::|)"), "\\_", "-"),
str_match,
string = ex_files
)
ex_incl <- ex_files[apply(! is.na(ex_match), 1L, any)]
# # find layer-specific examples
# ex_files <- list.files(here::here("inst/examples/"), "(stat|geom)-.*\\.(r|R)")
# # restrict to examples without home documentation files
# ex_match <- sapply(
# str_replace_all(str_remove(orig_layers, "^(.*::|)"), "\\_", "-"),
# str_match,
# string = ex_files
# )
# ex_incl <- ex_files[apply(! is.na(ex_match), 1L, any)]
# find layer-specific biplot examples
ex_incl <-
list.files(here::here("inst/examples/"), "(stat|geom)-.*-ord.*\\.(r|R)")
names(ex_incl) <-
str_replace(ex_incl, "^.*(stat|geom)\\-([a-z0-9]*).*$", "\\2 \\1")

# find layers from ggplot2 extensions to import/export
port_layers <- str_subset(orig_layers, "^ggplot2::", negate = TRUE)
Expand Down Expand Up @@ -446,9 +451,7 @@ for (type in c("stat", "geom")) {
adapt_examples <- if (length(ex_type) == 0L) "" else glue::glue(
str_c(
str_c(
"#' @example inst/examples/",
ex_type,
"\n",
"#' @example inst/examples/", ex_type, "\n",
collapse = ""
),
"\n"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions inst/examples/ex-stat-center.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ggplot(mpg, aes(x = displ, y = cty, shape = drv)) +
geom_point() +
stat_center(fun = "median", size = 5, alpha = .5)

ggplot(mpg, aes(x = displ, y = cty, shape = drv, linetype = drv)) +
stat_center(size = 3) +
stat_star()
File renamed without changes.
9 changes: 9 additions & 0 deletions inst/examples/ex-stat-chull.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ggplot(USJudgeRatings, aes(x = INTG, y = PREP)) +
geom_point() +
stat_chull(alpha = .5)

ggplot(USJudgeRatings, aes(x = INTG, y = PREP)) +
stat_peel(
aes(alpha = after_stat(hull)),
breaks = seq(.1, .9, .2), color = "black"
)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
judge_pca <- ordinate(USJudgeRatings, princomp)
judge_pca <- ordinate(USJudgeRatings, princomp, cols = -c(1, 12))
ggbiplot(judge_pca, axis.type = "predictive") +
geom_cols_axis() +
geom_rows_point(elements = "score") +
Expand Down
112 changes: 112 additions & 0 deletions man/biplot-stats.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 9 additions & 27 deletions man/stat_bagplot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 7 additions & 32 deletions man/stat_center.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 8 additions & 50 deletions man/stat_chull.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eab9675

Please sign in to comment.