Skip to content

Commit

Permalink
Version 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
prdm0 committed Apr 12, 2024
1 parent 414d377 commit 93fa5c6
Show file tree
Hide file tree
Showing 39 changed files with 45 additions and 28 deletions.
4 changes: 2 additions & 2 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Version: 0.1.0
Date: 2024-04-10 18:22:40 UTC
SHA: eb9f0eb16bd6b8e4b5952f5735463c60001c229e
Date: 2024-04-11 13:02:11 UTC
SHA: 414d3770676572b0b730ebc97c925b20722826b8
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ importFrom(ggplot2,aes)
importFrom(ggplot2,after_stat)
importFrom(ggplot2,element_text)
importFrom(ggplot2,geom_bar)
importFrom(ggplot2,geom_freqpoly)
importFrom(ggplot2,geom_histogram)
importFrom(ggplot2,geom_line)
importFrom(ggplot2,geom_point)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,labs)
importFrom(ggplot2,scale_color_manual)
importFrom(ggplot2,theme)
importFrom(glue,glue)
importFrom(graphics,hist)
importFrom(lbfgs,lbfgs)
importFrom(numDeriv,grad)
importFrom(parallel,detectCores)
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# AcceptReject 0.1.0

* Initial CRAN submission.

# AcceptReject 0.1.1

* In generating observations of continuous random variables, using histogram with the same breaks as the R graphics `hist()` function, in the histogram created by **ggplot2**.
1 change: 1 addition & 0 deletions R/accept_reject.r
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,6 @@ accept_reject <-
attr(r, "args_f") <- args_f
attr(r, "c") <- c
attr(r, "continuous") <- continuous
attr(r, "xlim") <- xlim
return(r)
}
22 changes: 12 additions & 10 deletions R/plot.r
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @param x An object of class `accept reject`
#' @param color_observed_density Observed density color (continuous case).
#' @param color_true_density True density color (continuous case)
#' @param color_true_density True histogram density color (continuous case)
#' @param color_bar Bar chart fill color (discrete case)
#' @param color_observable_point Color of generated points (discrete case)
#' @param color_real_point Color of real probability points (discrete case)
Expand All @@ -34,26 +34,27 @@
#'
#' @seealso [accept_reject()] and [print.accept_reject()].
#'
#' @importFrom ggplot2 ggplot aes after_stat geom_line geom_freqpoly geom_point
#' @importFrom ggplot2 ggplot aes after_stat geom_line geom_point geom_histogram
#' geom_bar labs scale_color_manual theme element_text
#' @importFrom glue glue
#' @importFrom rlang list2
#' @importFrom cli cli_alert_success cli_alert_info
#' @importFrom scales percent
#' @importFrom stats density
#' @importFrom graphics hist
#' @import rlang
#'
#' @examples
#' accept_reject(
#' n = 2000L,
#' n = 1000L,
#' f = dbinom,
#' continuous = FALSE,
#' args_f = list(size = 5, prob = 0.5),
#' xlim = c(0, 10)
#' ) |> plot()
#'
#' accept_reject(
#' n = 1000L,
#' n = 500L,
#' f = dnorm,
#' continuous = TRUE,
#' args_f = list(mean = 0, sd = 1),
Expand All @@ -64,9 +65,9 @@
plot.accept_reject <-
function(
x,
color_observed_density = "#FBBA78",
color_true_density = "#1D7DA5",
color_bar = "#FCEFC3",
color_observed_density = "#BB9FC9", #"#E65A65", # "#FBBA78",
color_true_density = "#E9796D",
color_bar = "#BB9FC9", #"#E65A65", #"#FCEFC3",
color_observable_point = "#7BBDB3",
color_real_point = "#FE4F0E",
alpha = .3,
Expand All @@ -90,14 +91,15 @@ plot.accept_reject <-
capture.output(
p <-
p +
ggplot2::geom_density(aes(y = after_stat(density), color = "Observed density"), fill = color_observed_density, alpha = alpha) +
ggplot2::geom_histogram(aes(y = after_stat(density), color = "Observed density"), fill = color_observed_density, alpha = alpha, breaks = hist(data$x, plot = FALSE)$breaks) +
#ggplot2::geom_density(aes(y = after_stat(density), color = "Observed density"), position = "stack", fill = color_observed_density, alpha = alpha) +
ggplot2::geom_line(aes(y = y, color = "True density")) +
ggplot2::scale_color_manual(values = c("True density" = color_true_density, "Observed density" = color_observed_density)) +
ggplot2::labs(
x = "x",
y = "f(x)",
title = "Probability density function",
subtitle = "Real x Observed",
subtitle = "True x Observed",
color = "Legend"
)
)
Expand All @@ -115,7 +117,7 @@ plot.accept_reject <-
x = "x",
y = "P(X = x)",
title = "Probability Function",
subtitle = "Real x Observed",
subtitle = "True x Observed",
color = "Legend"
)
)
Expand Down
Binary file modified docs/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion docs/articles/accept_reject.html

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/index.html

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

9 changes: 7 additions & 2 deletions docs/news/index.html

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

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pkgdown: 2.0.7
pkgdown_sha: ~
articles:
accept_reject: accept_reject.html
last_built: 2024-04-11T12:57Z
last_built: 2024-04-12T20:29Z

Binary file modified docs/reference/Rplot002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/accept_reject-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/accept_reject-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/figures/README-unnamed-chunk-2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/plot.accept_reject-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/plot.accept_reject-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/reference/plot.accept_reject.html

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

2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

Binary file modified man/figures/README-unnamed-chunk-2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions man/plot.accept_reject.Rd

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

Binary file modified pkgdown/favicon/apple-touch-icon-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pkgdown/favicon/favicon-16x16.png
Binary file modified pkgdown/favicon/favicon-32x32.png

0 comments on commit 93fa5c6

Please sign in to comment.