Skip to content

Commit

Permalink
Add back examples with package data
Browse files Browse the repository at this point in the history
  • Loading branch information
YuhangTom committed Sep 24, 2023
1 parent 1eb637f commit 84c0754
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 3 deletions.
12 changes: 11 additions & 1 deletion R/inside_polygon.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@
#' @importFrom concaveman concaveman
#' @importFrom tidyr pivot_longer
#' @export

#' @examples
#' x3p <- x3p_subsamples[[1]]
#' bounds <- x3p_boundary_points(x3p, 2)
#' polygon <- inside_polygon(bounds$x, bounds$y, 1)
#'
#' library(ggplot2)
#' library(dplyr)
#' bounds %>%
#' ggplot(aes(x = x, y = y)) + geom_point() +
#' geom_polygon(data = polygon)
#'
inside_polygon <- function(x, y, concavity, center = NULL) {
stopifnot(concavity > 0)

Expand Down
11 changes: 10 additions & 1 deletion R/x3p_boundary_points.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
#' @importFrom dplyr `%>%` group_by mutate filter summarize select
#' @importFrom rlang .data
#' @export

#' @examples
#' x3p <- x3p_subsamples[[1]]
#' bounds <- x3p_boundary_points(x3p, 2)
#'
#' library(ggplot2)
#' library(dplyr)
#' bounds %>%
#' ggplot(aes(x = x, y = y)) +
#' geom_point()
#'
x3p_boundary_points <- function(x3p, sample) {
stopifnot("x3p" %in% class(x3p))
x3p_df <- x3p %>%
Expand Down
7 changes: 6 additions & 1 deletion R/x3p_surface_polygon.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
#' @importFrom grDevices as.raster dev.off
#' @importFrom graphics par plot.default polygon
#' @export

#' @examples
#' if (interactive()) {
#' x3p <- x3p_subsamples[[1]]
#' x3p <- x3p %>% x3p_surface_polygon(sample=1)
#' x3p_image(x3p, size = dim(x3p$surface.matrix), zoom=.6)
#' }
x3p_surface_polygon <- function(x3p, colour = "red", sample = 10, center = NULL, concavity = 1.5) {
stopifnot("x3p" %in% class(x3p), is.numeric(concavity), concavity > 0)

Expand Down
12 changes: 12 additions & 0 deletions man/inside_polygon.Rd

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

11 changes: 11 additions & 0 deletions man/x3p_boundary_points.Rd

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

7 changes: 7 additions & 0 deletions man/x3p_surface_polygon.Rd

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

0 comments on commit 84c0754

Please sign in to comment.