Skip to content

Commit

Permalink
changes name to vizdraws
Browse files Browse the repository at this point in the history
  • Loading branch information
Ignacio Martinez committed Jul 7, 2019
1 parent 07399a6 commit 69b3c06
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 169 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: IMPosterior
Title: Visualize the Posterior Distribution
Version: 0.7
Package: vizdraws
Title: Visualize Draws from the Prior and Posterior Distributions
Version: 0.9
Authors@R: c(
person("Ignacio", "Martinez", email = "[email protected]", role = c("aut", "cre")),
person("Linus", "Marco", email = "[email protected]", role = "aut"),
person("Dan", "Thal", email = "[email protected]", role = "aut"))
Description: Plot the posterior distribution and the probabilities of being to the right or left of a threshold.
Description: Interactive visualization for the prior and posterior distribution.
License: GPL-3
Encoding: UTF-8
LazyData: true
Expand Down
2 changes: 1 addition & 1 deletion IMPosterior.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
PackageRoxygenize: rd,collate,namespace,vignette
6 changes: 3 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by roxygen2: do not edit by hand

export("%>%")
export(IMPosterior)
export(IMPosteriorOutput)
export(renderIMPosterior)
export(rendervizdraws)
export(vizdraws)
export(vizdrawsOutput)
importFrom(magrittr,"%>%")
53 changes: 32 additions & 21 deletions R/IMPosterior.R → R/vizdraws.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
#' @title IMPosterior
#' @param prior draws from the prior distribution. This is an optional parameter but either this or posterior should be provided.
#' @param posterior draws from the posterior distribution. This is an optional parameter but either this or prior should be provided.
#' @param MME minimum meaninful effect. If not provided MME is set to zero.
#' @title vizdraws
#'
#' @param prior draws from the prior distribution. This is an optional parameter but either this or posterior should be provided
#' @param posterior draws from the posterior distribution. This is an optional parameter but either this or prior should be provided
#' @param MME minimum meaninful effect. If not provided MME is set to zero
#' @param threshold if the probability is greater than this threshold, you would feel confortable making a decision
#' @param units optional arguement to specify the units of x. For example, dollars or applications.
#' @param units optional arguement to specify the units of x. For example, dollars or applications
#' @param colors colors for the left, middle, and right areas. The defaults are c("#e41a1c", "#377eb8", "#4daf4a")
#' @param width width for shiny
#' @param height height for shiny
#' @param elementId elementID for shiny
#' @return htmlwidget
#' @param quantity defaults to \code{FALSE}. When set to true text will change to reflect that you are predicting a quantity rather than a treatment effect
#' @param xlab defaults to \code{NULL}
#' @param breaks defaults to \code{NULL}
#' @param break_names defaults to \code{NULL}
#' @param xlim defaults to \code{NULL}
#' @param font_scale defaults to \code{1}
#' @param display_mode_name defaults to \code{FALSE}
#' @param title defaults to \code{''}
#' @param elementId Use an explicit element ID for the widget
#' (rather than an automatically generated one).elementID for shiny
#'
#' @return A HTML widget object
#' @export
#' @examples
#' if(interactive()){
#' set.seed(9782)
#' library(IMPosterior)
#' IMPosterior(prior= rnorm(100000))
#' library(vizdraws)
#' vizdraws(prior= rnorm(100000))
#' }

IMPosterior <- function(prior = NULL, posterior = NULL, MME = 0, threshold = NULL,
vizdraws <- function(prior = NULL, posterior = NULL, MME = 0, threshold = NULL,
units = NULL, quantity = FALSE, xlab = NULL,
breaks=NULL, break_names = NULL, colors = NULL,
width = NULL, height = NULL,
Expand Down Expand Up @@ -146,40 +157,40 @@ IMPosterior <- function(prior = NULL, posterior = NULL, MME = 0, threshold = NUL
)
# create widget
htmlwidgets::createWidget(
name = 'IMPosterior',
name = 'vizdraws',
opts,
width = width,
height = height,
package = 'IMPosterior',
package = 'vizdraws',
elementId = elementId,
sizingPolicy = sizingPolicy
)
}

#' Shiny bindings for IMPosterior
#' Shiny bindings for vizdraws
#'
#' Output and render functions for using IMPosterior within Shiny
#' Output and render functions for using vizdraws within Shiny
#' applications and interactive Rmd documents.
#'
#' @param outputId output variable to read from
#' @param width,height Must be a valid CSS unit (like \code{'100\%'},
#' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
#' string and have \code{'px'} appended.
#' @param expr An expression that generates a IMPosterior
#' @param expr An expression that generates a vizdraws
#' @param env The environment in which to evaluate \code{expr}.
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
#' is useful if you want to save an expression in a variable.
#'
#' @name IMPosterior-shiny
#' @name vizdraws-shiny
#'
#' @export
IMPosteriorOutput <- function(outputId, width = '100%', height = '100%'){
htmlwidgets::shinyWidgetOutput(outputId, 'IMPosterior', width, height, package = 'IMPosterior')
vizdrawsOutput <- function(outputId, width = '100%', height = '100%'){
htmlwidgets::shinyWidgetOutput(outputId, 'vizdraws', width, height, package = 'vizdraws')
}

#' @rdname IMPosterior-shiny
#' @rdname vizdraws-shiny
#' @export
renderIMPosterior <- function(expr, env = parent.frame(), quoted = FALSE) {
rendervizdraws <- function(expr, env = parent.frame(), quoted = FALSE) {
if (!quoted) { expr <- substitute(expr) } # force quoted
htmlwidgets::shinyRenderWidget(expr, IMPosteriorOutput, env, quoted = TRUE)
htmlwidgets::shinyRenderWidget(expr, vizdrawsOutput, env, quoted = TRUE)
}
8 changes: 4 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ knitr::opts_chunk$set(
)
```

# IMPosterior
# vizdraws

The goal of IMPosterior is to ...
vizdraws allows you to create interactive visualizations of draws from a prior and posterior distribution.

## Example

This is a basic example which shows you how to solve a common problem:

```{r example, eval=FALSE}
library(IMPosterior)
library(vizdraws)
set.seed(9782)
IMPosterior(prior = rnorm(10000, 0, 1), posterior = rnorm(10000, 1.1, 0.5), MME = 0.5, threshold = 0.8)
vizdraws(prior = rnorm(10000, 0, 1), posterior = rnorm(10000, 1.1, 0.5), MME = 0.5, threshold = 0.8)
```

![Posterior distribution](https://home.ignacio.website/Posterior.gif)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<!-- README.md is generated from README.Rmd. Please edit that file -->
vizdraws
========

IMPosterior
===========

The goal of IMPosterior is to …
vizdraws allows you to create interactive visualizations of draws from a
prior and posterior distribution.

Example
-------

This is a basic example which shows you how to solve a common problem:

``` r
library(IMPosterior)
library(vizdraws)
set.seed(9782)
IMPosterior(prior = rnorm(10000, 0, 1), posterior = rnorm(10000, 1.1, 0.5), MME = 0.5, threshold = 0.8)
vizdraws(prior = rnorm(10000, 0, 1), posterior = rnorm(10000, 1.1, 0.5), MME = 0.5, threshold = 0.8)
```

![Posterior distribution](https://home.ignacio.website/Posterior.gif)
Expand Down
42 changes: 0 additions & 42 deletions man/IMPosterior.Rd

This file was deleted.

20 changes: 10 additions & 10 deletions man/IMPosterior-shiny.Rd → man/vizdraws-shiny.Rd

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

61 changes: 61 additions & 0 deletions man/vizdraws.Rd

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

2 changes: 0 additions & 2 deletions vignettes/.gitignore

This file was deleted.

Loading

0 comments on commit 69b3c06

Please sign in to comment.