Skip to content

Commit

Permalink
Fix ggplot2 related bug (#34)
Browse files Browse the repository at this point in the history
* Fix ggplot2 related bug

* Version

* URL

* Travis
  • Loading branch information
FrankPortman authored Jul 2, 2019
1 parent 7c22a23 commit 2233cae
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ r_packages:
- covr

after_success:
- Rscript -e 'covr::codecov(line_exclusions = list("R/bandit.R", "src/init.cpp", "R/plotDists.R" = 78:104, "R/makePlots.R" = 43:95, "R/dists.R" = 42:48))'
- Rscript -e 'covr::codecov(line_exclusions = list("R/bandit.R", "src/init.cpp", "R/plotDists.R" = 80:106, "R/makePlots.R" = 43:95, "R/dists.R" = 42:48))'
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ Package: bayesAB
Type: Package
Title: Fast Bayesian Methods for AB Testing
Version: 1.1.2
Date: 2019-01-17
Date: 2019-07-02
Authors@R: person("Frank", "Portman", email = "frank1214@gmail.com", role = c("aut", "cre"))
Description: A suite of functions that allow the user to analyze A/B test
data in a Bayesian framework. Intended to be a drop-in replacement for
common frequentist hypothesis test such as the t-test and chi-sq test.
License: MIT + file LICENSE
Imports:
Rcpp (>= 0.12.4),
ggplot2 (>= 3.0.0),
methods
ggplot2 (>= 3.2.0),
methods,
rlang (>= 0.4.0)
LinkingTo: Rcpp
RoxygenNote: 6.1.0
Encoding: UTF-8
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export(rename)
importFrom(Rcpp,evalCpp)
importFrom(graphics,par)
importFrom(methods,is)
importFrom(rlang,.data)
importFrom(stats,dbeta)
importFrom(stats,dgamma)
importFrom(stats,dlnorm)
Expand Down
1 change: 1 addition & 0 deletions R/bayesAB.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#' @importFrom methods is
#' @importFrom stats dbeta dnorm qgamma quantile rbeta rgamma rnorm dgamma dpois qpois runif dlnorm qlnorm pnorm var
#' @importFrom utils tail packageVersion head
#' @importFrom rlang .data
#' @useDynLib bayesAB
#' @importFrom Rcpp evalCpp
NULL
2 changes: 1 addition & 1 deletion R/bayesTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
#'
#' @note For 'closed form' tests, you do not get a distribution over the posterior, but simply P(A > B) for the parameter in question.
#'
#' Choosing priors correctly is very important. Please see http://fportman.com/blog/bayesab-0-dot-7-0-plus-a-primer-on-priors/ for a detailed example of choosing priors
#' Choosing priors correctly is very important. Please see http://fportman.com/writing/bayesab-0-dot-7-0-plus-a-primer-on-priors/ for a detailed example of choosing priors
#' within bayesAB. Here are some ways to leverage objective/diffuse (assigning equal probability to all values) priors:
#'
#' \itemize{\item \code{Beta}(1, 1)
Expand Down
16 changes: 9 additions & 7 deletions R/plotDists.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' \item \link{plotPoisson}
#' }
#'
#' @note Choosing priors correctly is very important. Please see http://fportman.com/blog/bayesab-0-dot-7-0-plus-a-primer-on-priors/ for a detailed example of choosing priors
#' @note Choosing priors correctly is very important. Please see http://fportman.com/writing/bayesab-0-dot-7-0-plus-a-primer-on-priors/ for a detailed example of choosing priors
#' within bayesAB. Here are some ways to leverage objective/diffuse (assigning equal probability to all values) priors:
#'
#' \itemize{\item \code{Beta}(1, 1)
Expand All @@ -34,28 +34,30 @@ plotDist_ <- function(support, hseq, dist, params) {

discretes <- c('Poisson')

ribbon_or_bar <- ggplot2::geom_ribbon(ymin = 0,
ymax = hseq,
ribbon_or_bar <- ggplot2::geom_ribbon(ggplot2::aes(ymax = .data$hseq),
ymin = 0,
size = 2,
color = I("lightblue"),
fill = "lightgreen",
alpha = .25)

if(dist %in% discretes) {
ribbon_or_bar <- ggplot2::geom_bar(stat = "identity",
ribbon_or_bar <- ggplot2::geom_col(size = 2,
color = I("lightblue"),
fill = "lightgreen",
alpha = .25,
size = 2)
alpha = .25)
notEmpty <- hseq != 0
support <- support[notEmpty]
hseq <- hseq[notEmpty]
}

# Done after the if statement because we have to delete some stuff for discrete case
data <- data.frame(support, hseq)

paramList <- sapply(names(params), function(p) paste(p, params[p], sep = " = ", collapse = ""), USE.NAMES = FALSE)
paramList <- paste0(paramList, collapse = ", ")

p <- ggplot2::qplot(x = support, y = hseq, geom = "line") +
p <- ggplot2::ggplot(data, ggplot2::aes(support, hseq)) +
ggplot2::xlab(NULL) +
ggplot2::ylab('PDF') +
ggplot2::ggtitle(paste0(
Expand Down
10 changes: 5 additions & 5 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## Version 1.1.1 Submission
Minor release mainly for fixing bugs around the newest version of ggplot2. Two other minor bug fixes for functions to make them more correct.
## Version 1.1.2 Submission
Minor release for fixing a bug caused by latest release of ggplot2. No API changes.

## Test environments
- local OS X install, R 3.5.1
- ubuntu 12.04 (on travis-ci), R 3.5.1
- local OS X install, R 3.6.0
- ubuntu 14.04 (on travis-ci), R 3.6.0
- win-builder (devel and release)

## R CMD check results
There were no ERRORs or WARNINGs.
There were no ERRORs,WARNINGs, or NOTEs.

## Dependencies
There are currently no dependencies for this package.
2 changes: 1 addition & 1 deletion man/bayesTest.Rd

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

2 changes: 1 addition & 1 deletion man/plotDistributions.Rd

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

0 comments on commit 2233cae

Please sign in to comment.