Skip to content

Commit

Permalink
add ash as sugguest
Browse files Browse the repository at this point in the history
  • Loading branch information
huizezhang-sherry committed Sep 10, 2024
1 parent 15fbe17 commit c09930d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 37 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ Suggests:
forcats,
patchwork,
future.apply,
ash
Language: en-GB
38 changes: 20 additions & 18 deletions R/huber-plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,28 @@
#' @rdname huber
#' @export
#' @examples
#' library(ggplot2)
#' library(tourr)
#' data(randu)
#' randu_std <- as.data.frame(apply(randu, 2, function(x) (x-mean(x))/sd(x)))
#' randu_std$yz <- sqrt(35)/6*randu_std$y-randu_std$z/6
#' randu_df <- randu_std[c(1,4)]
#' randu_huber <- prep_huber(randu_df, index = norm_bin(nr = nrow(randu_df)))
#' if (require(ash, quietly = TRUE)) {
#' library(ggplot2)
#' library(tourr)
#' data(randu)
#' randu_std <- as.data.frame(apply(randu, 2, function(x) (x-mean(x))/sd(x)))
#' randu_std$yz <- sqrt(35)/6*randu_std$y-randu_std$z/6
#' randu_df <- randu_std[c(1,4)]
#' randu_huber <- prep_huber(randu_df, index = norm_bin(nr = nrow(randu_df)))
#'
#' ggplot() +
#' geom_huber(data = randu_huber$idx_df, aes(x = x, y = y)) +
#' geom_point(data = randu_df, aes(x = x, y = yz)) +
#' geom_abline(slope = randu_huber$slope, intercept = 0) +
#' theme_huber() +
#' coord_fixed()
#' ggplot() +
#' geom_huber(data = randu_huber$idx_df, aes(x = x, y = y)) +
#' geom_point(data = randu_df, aes(x = x, y = yz)) +
#' geom_abline(slope = randu_huber$slope, intercept = 0) +
#' theme_huber() +
#' coord_fixed()
#'
#' ggplot(randu_huber$proj_df, aes(x = x)) +
#' geom_histogram(breaks = seq(-2.2, 2.4, 0.12)) +
#' xlab("") + ylab("") +
#' theme_bw() +
#' theme(axis.text.y = element_blank())
#' ggplot(randu_huber$proj_df, aes(x = x)) +
#' geom_histogram(breaks = seq(-2.2, 2.4, 0.12)) +
#' xlab("") + ylab("") +
#' theme_bw() +
#' theme(axis.text.y = element_blank())
#'}
geom_huber <- function(mapping = NULL, data = NULL, stat = "identity",
position = "identity", ...,
show.legend = NA, inherit.aes = TRUE) {
Expand Down
2 changes: 1 addition & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ reference:
- botanical_pal
- starts_with("scale")
- theme_fern
- title: In-built data
- title: Data
desc: >
Simulated example data
contents:
Expand Down
38 changes: 20 additions & 18 deletions man/huber.Rd

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

0 comments on commit c09930d

Please sign in to comment.