diff --git a/DESCRIPTION b/DESCRIPTION index 562400b..796d02d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: WVPlots Type: Package Title: Common Plots for Analysis Version: 1.2.0 -Date: 2019-09-14 +Date: 2019-10-03 Authors@R: c( person("John", "Mount", email = "jmount@win-vector.com", role = c("aut", "cre")), person("Nina", "Zumel", email = "nzumel@win-vector.com", role = c("aut")), @@ -21,11 +21,11 @@ Depends: R (>= 3.4.0) Imports: ggplot2 (>= 2.2.0), - wrapr (>= 1.8.8), - sigr (>= 1.0.5), - cdata (>= 1.1.0), + wrapr (>= 1.9.0), + sigr (>= 1.0.6), + cdata (>= 1.1.2), rqdatatable (>= 1.2.2), - rquery, + rquery (>= 1.3.8), utils, grid, gridExtra, diff --git a/NAMESPACE b/NAMESPACE index 0ecfc24..a1d1a6b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -67,6 +67,7 @@ importFrom(stats,as.formula) importFrom(stats,binomial) importFrom(stats,complete.cases) importFrom(stats,dbeta) +importFrom(stats,dbinom) importFrom(stats,density) importFrom(stats,dnorm) importFrom(stats,ecdf) diff --git a/NEWS.md b/NEWS.md index a90c5b7..1bc7527 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# WVPlots 1.2.0 2019-09-14 +# WVPlots 1.2.0 2019-10-03 * Bring in rqdatatable for data aggregation tasks. diff --git a/R/PlotDistCountBinomial.R b/R/PlotDistCountBinomial.R index ff56043..6cd9d59 100644 --- a/R/PlotDistCountBinomial.R +++ b/R/PlotDistCountBinomial.R @@ -1,3 +1,7 @@ + +#' @importFrom stats dbinom +NULL + #' Plot count data with a theoretical binomial #' #' Compares empirical count data to a binomial distribution @@ -73,9 +77,10 @@ PlotDistCountBinomial = function(frm, xvar, trial_size, title, ..., # theoretical counts (not necessarily integral) dtheory = data.frame(x = 0:trial_size, - y = ntrials*dbinom(0:trial_size, trial_size, p)) + y = ntrials*stats::dbinom(0:trial_size, trial_size, p)) colnames(dtheory) = c(xvar, "number_of_observations") + one = 1 # don't look unbound # empirical counts demp = frm %.>% extend(., one=1) %.>% diff --git a/README.md b/README.md index 29e0b97..9216f76 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,24 @@ -WVPlots -======= -Common plots we use for analysis and presentation (on top of ggplot2 in [R](https://cran.r-project.org)). For an introduction please see: [here](http://www.win-vector.com/blog/2018/05/wvplots-now-at-version-1-0-0-on-cran/). +# WVPlots + +Common plots we use for analysis and presentation (on top of ggplot2 in +[R](https://cran.r-project.org)). For an introduction please see: +[here](http://www.win-vector.com/blog/2018/05/wvplots-now-at-version-1-0-0-on-cran/). Website: ![](https://github.com/WinVector/WVPlots/raw/master/tools/WVPlots.png) -More notes: +More + notes: -- -- -- + - + - + - ------------------------------------------------------------------------- +----- To install from CRAN: diff --git a/cran-comments.md b/cran-comments.md index 02f70dd..28123b3 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,40 +1,34 @@ ## Test environments - ### OSX - R CMD check --as-cran WVPlots_1.1.2.tar.gz - * using R version 3.6.1 (2019-07-05) + R CMD check --as-cran WVPlots_1.2.0.tar.gz + * using R version 3.6.0 (2019-04-26) * using platform: x86_64-apple-darwin15.6.0 (64-bit) * using session charset: UTF-8 * using option ‘--as-cran’ * checking for file ‘WVPlots/DESCRIPTION’ ... OK * checking extension type ... Package - * this is package ‘WVPlots’ version ‘1.1.2’ + * this is package ‘WVPlots’ version ‘1.2.0’ * checking CRAN incoming feasibility ... Note_to_CRAN_maintainers Maintainer: ‘John Mount ’ - * checking package namespace information ... OK - * checking package dependencies ... OK Status: OK ### Windows - devtools::check_win_devel() - rhub::check_for_cran() - 723#> * using R Under development (unstable) (2019-08-30 r77101) - 724#> * using platform: x86_64-w64-mingw32 (64-bit) - 725#> * using session charset: ISO8859-1 - 726#> * using option '--as-cran' - 727#> * checking for file 'WVPlots/DESCRIPTION' ... OK - 728#> * checking extension type ... Package - 729#> * this is package 'WVPlots' version '1.1.2' - 730#> * checking CRAN incoming feasibility ... Note_to_CRAN_maintainers - 731#> Maintainer: 'John Mount ' - 787#> Status: OK - + 720#> * using R Under development (unstable) (2019-09-18 r77193) + 721#> * using platform: x86_64-w64-mingw32 (64-bit) + 722#> * using session charset: ISO8859-1 + 723#> * using option '--as-cran' + 724#> * checking for file 'WVPlots/DESCRIPTION' ... OK + 725#> * checking extension type ... Package + 726#> * this is package 'WVPlots' version '1.2.0' + 727#> * checking CRAN incoming feasibility ... Note_to_CRAN_maintainers + 728#> Maintainer: 'John Mount ' + 784#> Status: OK ## Downstream dependencies diff --git a/docs/404.html b/docs/404.html index 928559b..215c220 100644 --- a/docs/404.html +++ b/docs/404.html @@ -67,7 +67,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -135,7 +135,7 @@

Page not found (404)

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index a0bece9..7346d56 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -67,7 +67,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -1160,7 +1160,7 @@

License

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/articles/WVPlots_concept.html b/docs/articles/WVPlots_concept.html index 86c97c3..f1ddae9 100644 --- a/docs/articles/WVPlots_concept.html +++ b/docs/articles/WVPlots_concept.html @@ -31,7 +31,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -85,7 +85,7 @@

WVPlots concept

Win-Vector LLC

-

2019-09-11

+

2019-10-03

Source: vignettes/WVPlots_concept.Rmd @@ -96,9 +96,9 @@

2019-09-11

Nina Zumel and I have been working on packaging our favorite graphing techniques in a more reusable way that emphasizes the analysis task at hand over the steps needed to produce a good visualization. The idea is: we sacrifice some of the flexibility and composability inherent to ggplot2 in R for a menu of prescribed presentation solutions.

For example the plot below showing both an observed discrete empirical distribution (as stems) and a matching theoretical distribution (as bars) is a built in “one liner.”

-
set.seed(52523)
-d <- data.frame(wt=100*rnorm(100))
-WVPlots::PlotDistCountNormal(d,'wt','example')
+
set.seed(52523)
+d <- data.frame(wt=100*rnorm(100))
+WVPlots::PlotDistCountNormal(d,'wt','example')

The graph above is actually the product of a number of presentation decisions:

    @@ -107,7 +107,7 @@

    2019-09-11

  • Automatically fitting and rendering the matching (properly count-scaled) normal distribution as thin translucent bars for easy comparison (again to try and de-emphasize area).

All of these decisions are triggered by choosing which plot to use from the WVPlots library. In this case we chose WVPlots::PlotDistCountNormal. For an audience of analysts we might choose an area/density based representation (by instead specifying WVPlots::PlotDistDensityNormal) which is shown below:

-
WVPlots::PlotDistDensityNormal(d,'wt','example')
+

Switching the chosen plot simultaneously changes many of the details of the presentation. WVPlots is designed to make this change simple by insisting an a very simple unified calling convention. The plot calls all insist on roughly the following arguments:

    @@ -118,57 +118,57 @@

    2019-09-11

This intentionally rigid calling interface is easy to remember and makes switching between plot types very easy. We have also make title a required argument, as we feel all plots should be labeled.

What we are trying to do is separate the specification of exactly what plot we want from the details of how to produce it. We find this separation of concerns and encapsulation of implementation allows us to routinely use rich annotated graphics. Below are a few more examples:

-
set.seed(34903490)
-x = rnorm(50)
-y = 0.5*x^2 + 2*x + rnorm(length(x))
-frm = data.frame(x=x,y=y,yC=y>=as.numeric(quantile(y,probs=0.8)))
-frm$absY <- abs(frm$y)
-frm$posY = frm$y > 0
-WVPlots::ScatterHist(frm, "x", "y", smoothmethod="lm", 
-                     title="Example Linear Fit")
+

-
set.seed(34903490)
-y = abs(rnorm(20)) + 0.1
-x = abs(y + 0.5*rnorm(20))
-
-frm = data.frame(model=x, value=y)
-
-frm$costs=1
-frm$costs[1]=5
-frm$rate = with(frm, value/costs)
-
-frm$isValuable = (frm$value >= as.numeric(quantile(frm$value, probs=0.8)))
-gainx = 0.10  # get the top 10% most valuable points as sorted by the model
-
-# make a function to calculate the label for the annotated point
-labelfun = function(gx, gy) {
-  pctx = gx*100
-  pcty = gy*100
-  
-  paste("The top ", pctx, "% most valuable points by the model\n",
-        "are ", pcty, "% of total actual value", sep='')
-}
-
-WVPlots::GainCurvePlotWithNotation(frm, "model", "value", 
-                                   title="Example Gain Curve with annotation", 
-                          gainx=gainx,labelfun=labelfun) 
+

-
set.seed(52523)
-d = data.frame(meas=rnorm(100))
-threshold = 1.5
-WVPlots::ShadedDensity(d, "meas", threshold, tail="right", 
-                       title="Example shaded density plot, right tail")
+

-
set.seed(34903490)
-frm = data.frame(x=rnorm(50),y=rnorm(50))
-frm$z <- frm$x+frm$y
-WVPlots::ScatterHistN(frm, "x", "y", "z", title="Example Joint Distribution")
+
set.seed(34903490)
+frm = data.frame(x=rnorm(50),y=rnorm(50))
+frm$z <- frm$x+frm$y
+WVPlots::ScatterHistN(frm, "x", "y", "z", title="Example Joint Distribution")

-
set.seed(34903490)
-x = rnorm(50)
-y = 0.5*x^2 + 2*x + rnorm(length(x))
-frm = data.frame(x=x,yC=y>=as.numeric(quantile(y,probs=0.8)))
-WVPlots::ROCPlot(frm, "x", "yC", TRUE, title="Example ROC plot")
+
set.seed(34903490)
+x = rnorm(50)
+y = 0.5*x^2 + 2*x + rnorm(length(x))
+frm = data.frame(x=x,yC=y>=as.numeric(quantile(y,probs=0.8)))
+WVPlots::ROCPlot(frm, "x", "yC", TRUE, title="Example ROC plot")

We know this collection doesn’t rise to the standard of a complete “grammar of graphics.” But it can become (through accumulation) a re-usable repository of a number of specific graphing tasks done well. It is also a chance to eventually document presentation design decisions (though we haven’t gotten far on that yet). The complete set of graphs is shown in the WVPlots_example vignette.

@@ -186,7 +186,7 @@

2019-09-11

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/articles/WVPlots_examples.html b/docs/articles/WVPlots_examples.html index 794930b..7f190a9 100644 --- a/docs/articles/WVPlots_examples.html +++ b/docs/articles/WVPlots_examples.html @@ -31,7 +31,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -85,7 +85,7 @@

Example WVPlots

Win-Vector LLC

-

2019-09-11

+

2019-10-03

Source: vignettes/WVPlots_examples.Rmd @@ -94,165 +94,165 @@

2019-09-11

-

Some example data science plots in R using ggplot2. See https://github.com/WinVector/WVPlots for code/details.

-
set.seed(34903490)
-x = rnorm(50)
-y = 0.5*x^2 + 2*x + rnorm(length(x))
-frm = data.frame(x=x,y=y,yC=y>=as.numeric(quantile(y,probs=0.8)))
-frm$absY <- abs(frm$y)
-frm$posY = frm$y > 0
+

Some example data science plots in R using ggplot2. See https://github.com/WinVector/WVPlots for code/details.

+

Scatterplots

Scatterplot with smoothing line through points.

-
WVPlots::ScatterHist(frm, "x", "y", title="Example Fit")
+
WVPlots::ScatterHist(frm, "x", "y", title="Example Fit")

Scatterplot with best linear fit through points. Also report the R-squared and significance of the linear fit.

-
WVPlots::ScatterHist(frm, "x", "y", smoothmethod="lm", 
-                     title="Example Linear Fit", estimate_sig = TRUE)
+

Scatterplot compared to the line x = y. Also report the coefficient of determination between x and y (where y is “true outcome” and x is “predicted outcome”).

-
WVPlots::ScatterHist(frm, "x", "y", smoothmethod="identity", 
-                     title="Example Relation Plot", estimate_sig = TRUE)
+

Scatterplot of (x, y) color-coded by category/group, with marginal distributions of x and y conditioned on group.

-
set.seed(34903490)
-fmScatterHistC = data.frame(x=rnorm(50),y=rnorm(50))
-fmScatterHistC$cat <- fmScatterHistC$x+fmScatterHistC$y>0
-WVPlots::ScatterHistC(fmScatterHistC, "x", "y", "cat", title="Example Conditional Distribution")
+
set.seed(34903490)
+fmScatterHistC = data.frame(x=rnorm(50),y=rnorm(50))
+fmScatterHistC$cat <- fmScatterHistC$x+fmScatterHistC$y>0
+WVPlots::ScatterHistC(fmScatterHistC, "x", "y", "cat", title="Example Conditional Distribution")

Scatterplot of (x, y) color-coded by discretized z. The continuous variable z is binned into three groups, and then plotted as by ScatterHistC

-
set.seed(34903490)
-frmScatterHistN = data.frame(x=rnorm(50),y=rnorm(50))
-frmScatterHistN$z <- frmScatterHistN$x+frmScatterHistN$y
-WVPlots::ScatterHistN(frmScatterHistN, "x", "y", "z", title="Example Joint Distribution")
+
set.seed(34903490)
+frmScatterHistN = data.frame(x=rnorm(50),y=rnorm(50))
+frmScatterHistN$z <- frmScatterHistN$x+frmScatterHistN$y
+WVPlots::ScatterHistN(frmScatterHistN, "x", "y", "z", title="Example Joint Distribution")

Plot the relationship y as a function of x with a smoothing curve that estimates \(E[y | x]\). If y is a 0/1 variable as below (binary classification, where 1 is the target class), then the smoothing curve estimates \(P(y | x)\). Since \(y \in \{0,1\}\) with \(y\) intended to be monotone in \(x\) is the most common use of this graph, BinaryYScatterPlot uses a glm smoother by default (use_glm=TRUE, this is essentially Platt scaling), as the best estimate of \(P(y | x)\).

-
WVPlots::BinaryYScatterPlot(frm, "x", "posY", use_glm=FALSE,
-                            title="Example 'Probability of Y' Plot (ggplot2 smoothing)")
+
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

-
WVPlots::BinaryYScatterPlot(frm, "x", "posY", use_glm=TRUE, 
-                            title="Example 'Probability of Y' Plot (GLM smoothing)")
+

Hexbin Plot

-
if(requireNamespace("hexbin", quietly = TRUE)) {
-  set.seed(5353636)
-  
-  df = rbind(data.frame(x=rnorm(1000, mean = 1), y=rnorm(1000, mean = 1, sd = 0.5 )),
-             data.frame(x = rnorm(1000, mean = -1, sd = 0.5), y = rnorm(1000, mean = -1, sd = 0.5)))
-  
-  print(WVPlots::HexBinPlot(df, "x", "y", "Two gaussians"))
-}
+
if(requireNamespace("hexbin", quietly = TRUE)) {
+  set.seed(5353636)
+  
+  df = rbind(data.frame(x=rnorm(1000, mean = 1), y=rnorm(1000, mean = 1, sd = 0.5 )),
+             data.frame(x = rnorm(1000, mean = -1, sd = 0.5), y = rnorm(1000, mean = -1, sd = 0.5)))
+  
+  print(WVPlots::HexBinPlot(df, "x", "y", "Two gaussians"))
+}

Gain Curves

-
set.seed(34903490)
-y = abs(rnorm(20)) + 0.1
-x = abs(y + 0.5*rnorm(20))
-
-frm = data.frame(model=x, value=y)
-
-frm$costs=1
-frm$costs[1]=5
-frm$rate = with(frm, value/costs)
-
-frm$isValuable = (frm$value >= as.numeric(quantile(frm$value, probs=0.8)))
+
set.seed(34903490)
+y = abs(rnorm(20)) + 0.1
+x = abs(y + 0.5*rnorm(20))
+
+frm = data.frame(model=x, value=y)
+
+frm$costs=1
+frm$costs[1]=5
+frm$rate = with(frm, value/costs)
+
+frm$isValuable = (frm$value >= as.numeric(quantile(frm$value, probs=0.8)))

Basic curve: each item “costs” the same. The wizard sorts by true value, the x axis sorts by the model, and plots the fraction of the total population.

-
WVPlots::GainCurvePlot(frm, "model", "value", title="Example Continuous Gain Curve")
+
WVPlots::GainCurvePlot(frm, "model", "value", title="Example Continuous Gain Curve")

We can annotate a point of the model at a specific x value

-
gainx = 0.10  # get the top 10% most valuable points as sorted by the model
-
-# make a function to calculate the label for the annotated point
-labelfun = function(gx, gy) {
-  pctx = gx*100
-  pcty = gy*100
-  
-  paste("The top ", pctx, "% most valuable points by the model\n",
-        "are ", pcty, "% of total actual value", sep='')
-}
-
-WVPlots::GainCurvePlotWithNotation(frm, "model", "value", 
-                                   title="Example Gain Curve with annotation", 
-                          gainx=gainx,labelfun=labelfun) 
+

When the x values have different costs, take that into account in the gain curve. The wizard now sorts by value/cost, and the x axis is sorted by the model, but plots the fraction of total cost, rather than total count.

-
WVPlots::GainCurvePlotC(frm, "model", "costs", "value", title="Example Continuous Gain CurveC")
+
WVPlots::GainCurvePlotC(frm, "model", "costs", "value", title="Example Continuous Gain CurveC")

ROC Plots

-
WVPlots::ROCPlot(frm, "model", "isValuable", TRUE, title="Example ROC plot")
+
WVPlots::ROCPlot(frm, "model", "isValuable", TRUE, title="Example ROC plot")

-
set.seed(34903490)
-x1 = rnorm(50)
-x2 = rnorm(length(x1))
-y = 0.2*x2^2 + 0.5*x2 + x1 + rnorm(length(x1))
-frmP = data.frame(x1=x1,x2=x2,yC=y>=as.numeric(quantile(y,probs=0.8)))
-# WVPlots::ROCPlot(frmP, "x1", "yC", TRUE, title="Example ROC plot")
-# WVPlots::ROCPlot(frmP, "x2", "yC", TRUE, title="Example ROC plot")
-WVPlots::ROCPlotPair(frmP, "x1", "x2", "yC", TRUE, title="Example ROC pair plot")
+

Precision-Recall Plot

-
WVPlots::PRPlot(frm, "model", "isValuable", TRUE, title="Example Precision-Recall plot")
+
WVPlots::PRPlot(frm, "model", "isValuable", TRUE, title="Example Precision-Recall plot")

Double Density Plot

-
WVPlots::DoubleDensityPlot(frm, "model", "isValuable", title="Example double density plot")
+
WVPlots::DoubleDensityPlot(frm, "model", "isValuable", title="Example double density plot")

Double Histogram Plot

-
WVPlots::DoubleHistogramPlot(frm, "model", "isValuable", title="Example double histogram plot")
+
WVPlots::DoubleHistogramPlot(frm, "model", "isValuable", title="Example double histogram plot")

Cleveland Style Dotplots

-
set.seed(34903490)
-
-# discrete variable: letters of the alphabet
-# frequencies of letters in English
-# source: http://en.algoritmy.net/article/40379/Letter-frequency-English
-letterFreqs = c(8.167, 1.492, 2.782, 4.253, 12.702, 2.228,
-                2.015, 6.094, 6.966, 0.153, 0.772, 4.025, 2.406, 6.749, 7.507, 1.929,
-                0.095, 5.987, 6.327, 9.056, 2.758, 0.978, 2.360, 0.150, 1.974, 0.074)
-letterFreqs = letterFreqs/100
-letterFrame = data.frame(letter = letters, freq=letterFreqs)
-
-# now let's generate letters according to their letter frequencies
-N = 1000
-randomDraws = data.frame(draw=1:N, letter=sample(letterFrame$letter, size=N, replace=TRUE, prob=letterFrame$freq))
-
-WVPlots::ClevelandDotPlot(randomDraws, "letter", title = "Example Cleveland-style dot plot")
+

-
WVPlots::ClevelandDotPlot(randomDraws, "letter", limit_n = 10,  title = "Top 10 most frequent letters")
+
WVPlots::ClevelandDotPlot(randomDraws, "letter", limit_n = 10,  title = "Top 10 most frequent letters")

-
WVPlots::ClevelandDotPlot(randomDraws, "letter", sort=0, title="Example Cleveland-style dot plot, unsorted")
+
WVPlots::ClevelandDotPlot(randomDraws, "letter", sort=0, title="Example Cleveland-style dot plot, unsorted")

-
WVPlots::ClevelandDotPlot(randomDraws, "letter", sort=1, stem=FALSE, title="Example with increasing sort order + coord_flip, no stem") + ggplot2::coord_flip()
+
WVPlots::ClevelandDotPlot(randomDraws, "letter", sort=1, stem=FALSE, title="Example with increasing sort order + coord_flip, no stem") + ggplot2::coord_flip()

ClevelandDotPlot also accepts an integral x variable. You probably want sort = 0 in this case.

-
set.seed(34903490)
-N = 1000
-ncar_vec = 0:5
-prob = c(1.5, 3, 3.5, 2, 1, 0.75); prob = prob/sum(prob)
-
-df = data.frame(num_cars = sample(ncar_vec, size = N, replace = TRUE, prob=prob))
-WVPlots::ClevelandDotPlot(df, "num_cars", sort = 0, title = "Distribution of household vehicle ownership")
+
set.seed(34903490)
+N = 1000
+ncar_vec = 0:5
+prob = c(1.5, 3, 3.5, 2, 1, 0.75); prob = prob/sum(prob)
+
+df = data.frame(num_cars = sample(ncar_vec, size = N, replace = TRUE, prob=prob))
+WVPlots::ClevelandDotPlot(df, "num_cars", sort = 0, title = "Distribution of household vehicle ownership")

@@ -260,124 +260,124 @@

Shadow Plots

Plot a bar chart of row counts conditioned on the categorical variable condvar, faceted on a second categorical variable, refinevar. Each faceted plot also shows a “shadow plot” of the totals conditioned on condvar alone.

This plot enables comparisons of sub-population totals across both condvar and refinevar simultaneously.

-
set.seed(354534)
-N = 100
-
-# rough proportions of eye colors
-eprobs = c(0.37, 0.36, 0.16, 0.11)
-
-eye_color  = sample(c("Brown", "Blue", "Hazel", "Green"), size = N, replace = TRUE, prob = eprobs)
-sex = sample(c("Male", "Female"), size = N, replace = TRUE)
-
-# A data frame of eye color by sex
-dframe = data.frame(eye_color = eye_color, sex = sex)
-
-WVPlots::ShadowPlot(dframe, "eye_color", "sex", title = "Shadow plot of eye colors by sex")
+
set.seed(354534)
+N = 100
+
+# rough proportions of eye colors
+eprobs = c(0.37, 0.36, 0.16, 0.11)
+
+eye_color  = sample(c("Brown", "Blue", "Hazel", "Green"), size = N, replace = TRUE, prob = eprobs)
+sex = sample(c("Male", "Female"), size = N, replace = TRUE)
+
+# A data frame of eye color by sex
+dframe = data.frame(eye_color = eye_color, sex = sex)
+
+WVPlots::ShadowPlot(dframe, "eye_color", "sex", title = "Shadow plot of eye colors by sex")

Shadow Histogram

Plot a histogram of a continuous variable xvar, faceted on a categorical conditioning variable, condvar. Each faceted plot also shows a “shadow plot” of the unconditioned histogram for comparison.

-
set.seed(354534)
-N = 100
-
-dframe = data.frame(x = rnorm(N), gp = "region 2", stringsAsFactors = FALSE)
-dframe$gp = with(dframe, ifelse(x < -0.5, "region 1", 
-                                ifelse(x > 0.5, "region 3", gp)))
-
-WVPlots::ShadowHist(dframe, "x", "gp", title = "X values by region")
+
set.seed(354534)
+N = 100
+
+dframe = data.frame(x = rnorm(N), gp = "region 2", stringsAsFactors = FALSE)
+dframe$gp = with(dframe, ifelse(x < -0.5, "region 1", 
+                                ifelse(x > 0.5, "region 3", gp)))
+
+WVPlots::ShadowHist(dframe, "x", "gp", title = "X values by region")

ShadowHist uses the Brewer Dark2 palette by default. You can pass in another Brewer palette to change the color scheme. If you prefer all the histograms to be the same color, set monochrome=TRUE.

-
WVPlots::ShadowHist(dframe, "x", "gp", title = "X values by region", monochrome=TRUE) 
+
WVPlots::ShadowHist(dframe, "x", "gp", title = "X values by region", monochrome=TRUE) 

To use a non-Brewer palette, such as viridis, or a manual color map, set palette=NULL. Here’s an example of setting the color palette manually.

-
colormap = c("#1F968BFF", "#29AF7FFF", "#55C667FF")
-
-WVPlots::ShadowHist(dframe, "x", "gp", title = "X values by region", palette=NULL) +
-  ggplot2::scale_fill_manual(values=colormap)
+
colormap = c("#1F968BFF", "#29AF7FFF", "#55C667FF")
+
+WVPlots::ShadowHist(dframe, "x", "gp", title = "X values by region", palette=NULL) +
+  ggplot2::scale_fill_manual(values=colormap)

ScatterBox Plots

-
classes = c("a", "b", "c")
-means = c(2, 4, 3)
-names(means) = classes
-label = sample(classes, size=1000, replace=TRUE)
-meas = means[label] + rnorm(1000)
-frm2 = data.frame(label=label,
-                  meas = meas)
-
-WVPlots::ScatterBoxPlot(frm2, "label", "meas", pt_alpha=0.2, title="Example Scatter/Box plot")
+
classes = c("a", "b", "c")
+means = c(2, 4, 3)
+names(means) = classes
+label = sample(classes, size=1000, replace=TRUE)
+meas = means[label] + rnorm(1000)
+frm2 = data.frame(label=label,
+                  meas = meas)
+
+WVPlots::ScatterBoxPlot(frm2, "label", "meas", pt_alpha=0.2, title="Example Scatter/Box plot")

-
WVPlots::ScatterBoxPlotH(frm2, "meas", "label",  pt_alpha=0.2, title="Example Scatter/Box plot")
+
WVPlots::ScatterBoxPlotH(frm2, "meas", "label",  pt_alpha=0.2, title="Example Scatter/Box plot")

Discrete Distribution Plot

-
frmx = data.frame(x = rbinom(1000, 20, 0.5))
-WVPlots::DiscreteDistribution(frmx, "x","Discrete example")
+
frmx = data.frame(x = rbinom(1000, 20, 0.5))
+WVPlots::DiscreteDistribution(frmx, "x","Discrete example")

Distribution and Count Plot

-
set.seed(52523)
-d <- data.frame(wt=100*rnorm(100))
-WVPlots::PlotDistCountNormal(d,'wt','example')
+
set.seed(52523)
+d <- data.frame(wt=100*rnorm(100))
+WVPlots::PlotDistCountNormal(d,'wt','example')

-
WVPlots::PlotDistDensityNormal(d,'wt','example')
+

Smoothed Scatterplots

-
y = c(1,2,3,4,5,10,15,18,20,25)
-x = seq_len(length(y))
-df = data.frame(x=x,y=y)
-
-WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", NULL, title="centered smooth, one group")
+
y = c(1,2,3,4,5,10,15,18,20,25)
+x = seq_len(length(y))
+df = data.frame(x=x,y=y)
+
+WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", NULL, title="centered smooth, one group")

-
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", NULL, title="left smooth, one group", align="left")
+
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", NULL, title="left smooth, one group", align="left")

-
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", NULL, title="right smooth, one group", align="right")
+
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", NULL, title="right smooth, one group", align="right")

-
n = length(x)
-df = rbind(data.frame(x=x, y=y+rnorm(n), gp="times 1"),
-           data.frame(x=x, y=0.5*y + rnorm(n), gp="times 1/2"),
-           data.frame(x=x, y=2*y + rnorm(n), gp="times 2"))
-
-WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", "gp", title="centered smooth, multigroup")
+
n = length(x)
+df = rbind(data.frame(x=x, y=y+rnorm(n), gp="times 1"),
+           data.frame(x=x, y=0.5*y + rnorm(n), gp="times 1/2"),
+           data.frame(x=x, y=2*y + rnorm(n), gp="times 2"))
+
+WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", "gp", title="centered smooth, multigroup")

-
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", "gp", title="left smooth, multigroup", align="left")
+
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", "gp", title="left smooth, multigroup", align="left")

-
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", "gp", title="right smooth, multigroup", align="right")
+
WVPlots::ConditionalSmoothedScatterPlot(df, "x", "y", "gp", title="right smooth, multigroup", align="right")

Density Plot with Shaded Tail

-
set.seed(52523)
-d = data.frame(meas=rnorm(100))
-threshold = -1.5
-WVPlots::ShadedDensity(d, "meas", threshold, 
-                       title="Example shaded density plot, left tail")
+

-
WVPlots::ShadedDensity(d, "meas", -threshold, tail="right", 
-                       title="Example shaded density plot, right tail")
+

Density Plot with Shaded Central Region

-
set.seed(52523)
-d = data.frame(meas=rnorm(100))
-# first and third quartiles of the data (central 50%)
-boundaries = quantile(d$meas, c(0.25, 0.75))
-WVPlots::ShadedDensityCenter(d, "meas", boundaries, 
-                       title="Example center-shaded density plot")
+

@@ -417,7 +417,7 @@

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/articles/index.html b/docs/articles/index.html index 970cd93..d7fac30 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -67,7 +67,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -140,7 +140,7 @@

All vignettes

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/authors.html b/docs/authors.html index f63218e..0053306 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -67,7 +67,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -148,7 +148,7 @@

Authors

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/index.html b/docs/index.html index 23a9b69..3154ac6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -34,7 +34,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -98,7 +98,7 @@

To install from CRAN:

-
install.packages('WVPlots')
+
install.packages('WVPlots')
@@ -140,7 +140,7 @@

Developers

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/news/index.html b/docs/news/index.html index 120ab2a..6fb139e 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -67,7 +67,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -122,9 +122,17 @@

Changelog

Source: NEWS.md +
+

+WVPlots 1.2.0 2019-10-03 Unreleased +

+
    +
  • Bring in rqdatatable for data aggregation tasks.
  • +
+

-WVPlots 1.1.2 2019-09-10 Unreleased +WVPlots 1.1.2 2019-09-10 2019-09-12

  • Allowed palette controls on more plots.
  • @@ -361,6 +369,7 @@

    Contents

    -

    Site built with pkgdown 1.4.0.

    +

    Site built with pkgdown 1.4.1.

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 95e144c..42b58f9 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,5 +1,5 @@ -pandoc: 1.19.2.1 -pkgdown: 1.4.0 +pandoc: 2.3.1 +pkgdown: 1.4.1 pkgdown_sha: ~ articles: WVPlots_concept: WVPlots_concept.html diff --git a/docs/reference/BinaryYScatterPlot.html b/docs/reference/BinaryYScatterPlot.html index 68c34d0..883e2aa 100644 --- a/docs/reference/BinaryYScatterPlot.html +++ b/docs/reference/BinaryYScatterPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0

@@ -212,7 +212,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ClevelandDotPlot.html b/docs/reference/ClevelandDotPlot.html index d65e5e9..3671423 100644 --- a/docs/reference/ClevelandDotPlot.html +++ b/docs/reference/ClevelandDotPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -220,7 +220,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ConditionalSmoothedScatterPlot.html b/docs/reference/ConditionalSmoothedScatterPlot.html index a038582..84bfb12 100644 --- a/docs/reference/ConditionalSmoothedScatterPlot.html +++ b/docs/reference/ConditionalSmoothedScatterPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -218,7 +218,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/DiscreteDistribution.html b/docs/reference/DiscreteDistribution.html index 101145b..2207080 100644 --- a/docs/reference/DiscreteDistribution.html +++ b/docs/reference/DiscreteDistribution.html @@ -70,7 +70,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -187,7 +187,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/DoubleDensityPlot.html b/docs/reference/DoubleDensityPlot.html index 677c6b9..5657d67 100644 --- a/docs/reference/DoubleDensityPlot.html +++ b/docs/reference/DoubleDensityPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -217,7 +217,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/DoubleHistogramPlot.html b/docs/reference/DoubleHistogramPlot.html index a4e57da..61a8f1b 100644 --- a/docs/reference/DoubleHistogramPlot.html +++ b/docs/reference/DoubleHistogramPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -210,7 +210,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/GainCurvePlot.html b/docs/reference/GainCurvePlot.html index a2a1e1f..04006ef 100644 --- a/docs/reference/GainCurvePlot.html +++ b/docs/reference/GainCurvePlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -225,7 +225,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/GainCurvePlotC.html b/docs/reference/GainCurvePlotC.html index 6870ffd..46b923a 100644 --- a/docs/reference/GainCurvePlotC.html +++ b/docs/reference/GainCurvePlotC.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -227,7 +227,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/GainCurvePlotWithNotation.html b/docs/reference/GainCurvePlotWithNotation.html index a63e5cf..b4c3715 100644 --- a/docs/reference/GainCurvePlotWithNotation.html +++ b/docs/reference/GainCurvePlotWithNotation.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -245,7 +245,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/HexBinPlot.html b/docs/reference/HexBinPlot.html index 16973a3..b7eec37 100644 --- a/docs/reference/HexBinPlot.html +++ b/docs/reference/HexBinPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -230,7 +230,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/LiftCurvePlot.html b/docs/reference/LiftCurvePlot.html index 356c5c5..50955cc 100644 --- a/docs/reference/LiftCurvePlot.html +++ b/docs/reference/LiftCurvePlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -219,7 +219,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/LogLogPlot.html b/docs/reference/LogLogPlot.html index abfdf23..e83fe28 100644 --- a/docs/reference/LogLogPlot.html +++ b/docs/reference/LogLogPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -218,7 +218,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/PRPlot.html b/docs/reference/PRPlot.html index d2e7f1e..c4d085b 100644 --- a/docs/reference/PRPlot.html +++ b/docs/reference/PRPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -206,7 +206,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/PRTPlot.html b/docs/reference/PRTPlot.html index 3742cf6..03f74c4 100644 --- a/docs/reference/PRTPlot.html +++ b/docs/reference/PRTPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -195,7 +195,7 @@

Examp frm$absY <- abs(frm$y) frm$posY = frm$y > 0 frm$costX = 1 -WVPlots::PRTPlot(frm, "x", "yC", TRUE, title="Example Precision-Recall threshold plot")
+WVPlots::PRTPlot(frm, "x", "yC", TRUE, title="Example Precision-Recall threshold plot")
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/PairPlot-2.png b/docs/reference/PairPlot-2.png index 9ab02dc..15f4dd5 100644 Binary files a/docs/reference/PairPlot-2.png and b/docs/reference/PairPlot-2.png differ diff --git a/docs/reference/PairPlot-3.png b/docs/reference/PairPlot-3.png new file mode 100644 index 0000000..9ab02dc Binary files /dev/null and b/docs/reference/PairPlot-3.png differ diff --git a/docs/reference/PairPlot.html b/docs/reference/PairPlot.html index a248896..b7f4367 100644 --- a/docs/reference/PairPlot.html +++ b/docs/reference/PairPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -180,14 +180,14 @@

Details

Examples

-PairPlot(iris, colnames(iris)[1:4], "Example plot", group_var = "Species")
+PairPlot(iris, colnames(iris)[1:4], "Example plot", group_var = "Species")
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
# custom palette colormap = c('#a6611a', '#dfc27d', '#018571') PairPlot(iris, colnames(iris)[1:4], "Example plot", group_var = "Species", palette=NULL) + - scale_color_manual(values=colormap)
#> Error in scale_color_manual(values = colormap): could not find function "scale_color_manual"
+ ggplot2::scale_color_manual(values=colormap)
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
# no color-coding -PairPlot(iris, colnames(iris)[1:4], "Example plot")
+PairPlot(iris, colnames(iris)[1:4], "Example plot")
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/PlotDistCountBinomial-1.png b/docs/reference/PlotDistCountBinomial-1.png new file mode 100644 index 0000000..27382fe Binary files /dev/null and b/docs/reference/PlotDistCountBinomial-1.png differ diff --git a/docs/reference/PlotDistCountBinomial-2.png b/docs/reference/PlotDistCountBinomial-2.png new file mode 100644 index 0000000..a4a999e Binary files /dev/null and b/docs/reference/PlotDistCountBinomial-2.png differ diff --git a/docs/reference/PlotDistCountBinomial-3.png b/docs/reference/PlotDistCountBinomial-3.png new file mode 100644 index 0000000..e6f559a Binary files /dev/null and b/docs/reference/PlotDistCountBinomial-3.png differ diff --git a/docs/reference/PlotDistCountBinomial.html b/docs/reference/PlotDistCountBinomial.html new file mode 100644 index 0000000..54293fe --- /dev/null +++ b/docs/reference/PlotDistCountBinomial.html @@ -0,0 +1,244 @@ + + + + + + + + +Plot count data with a theoretical binomial — PlotDistCountBinomial • WVPlots + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Compares empirical count data to a binomial distribution

+
+ +
PlotDistCountBinomial(frm, xvar, trial_size, title, ..., p = NULL,
+  limit_to_observed_range = FALSE, count_color = "black",
+  binom_color = "blue")
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
frm

data frame to get values from

xvar

column of frm that counts the number of successes for each trial

trial_size

the number of "coin flips" in a trial

title

title to place on plot

...

no unnamed argument, added to force named binding of later arguments.

p

mean of the binomial. If NULL, use empirical mean

limit_to_observed_range

If TRUE, limit plot to observed counts

count_color

color of empirical distribution

binom_color

color of theoretical binomial

+ +

Details

+ +

This function is useful for comparing the number of successes that occur +in a series of trials, all of the same size, to a binomial of a given +success-probability.

+

Plots the empirical distribution of successes, and a theoretical matching binomial. If +the mean of the binomial, p, is given, the binomial with success-probability +p is plotted. Otherwise, p is taken to be the pooled success rate +of the data: sum(frm[[xvar]]) / (trial_size*nrow(frm)). The mean of +the binomial is reported in the subtitle of the plot (to three significant figures).

+

If limit_to_observed_range is TRUE, the range of the plot will only cover +the range of the empirical data. Otherwise, the range of the plot will be +0:trial_size (the default).

+

See also

+ + + +

Examples

+
set.seed(23590) +class_size = 35 +nclasses = 100 +true_frate = 0.4 +fdata = data.frame(n_female = rbinom(nclasses, class_size, true_frate)) + +title = paste("Distribution of count of female students, class size =", class_size) +# compare to empirical p +PlotDistCountBinomial(fdata, "n_female", class_size, title)
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
+# compare to theoretical p of 0.5 +PlotDistCountBinomial(fdata, "n_female", class_size, title, + p = 0.5)
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
+# Example where the distribution is not of a true single binomial +fdata2 = rbind(data.frame(n_female = rbinom(50, class_size, 0.25)), + data.frame(n_female = rbinom(10, class_size, 0.60)) ) +PlotDistCountBinomial(fdata2, "n_female", class_size, title)
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.4.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/reference/PlotDistCountNormal.html b/docs/reference/PlotDistCountNormal.html index f202486..738886e 100644 --- a/docs/reference/PlotDistCountNormal.html +++ b/docs/reference/PlotDistCountNormal.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -209,7 +209,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/PlotDistDensityBeta-1.png b/docs/reference/PlotDistDensityBeta-1.png index 0c503e7..15a4129 100644 Binary files a/docs/reference/PlotDistDensityBeta-1.png and b/docs/reference/PlotDistDensityBeta-1.png differ diff --git a/docs/reference/PlotDistDensityBeta-2.png b/docs/reference/PlotDistDensityBeta-2.png index 9e1aaf5..9301ac4 100644 Binary files a/docs/reference/PlotDistDensityBeta-2.png and b/docs/reference/PlotDistDensityBeta-2.png differ diff --git a/docs/reference/PlotDistDensityBeta.html b/docs/reference/PlotDistDensityBeta.html index 9cdbebf..d468fb6 100644 --- a/docs/reference/PlotDistDensityBeta.html +++ b/docs/reference/PlotDistDensityBeta.html @@ -6,7 +6,7 @@ -Plot an empirical density with the matching beta distribution — PlotDistDensityBeta • WVPlots +Plot empirical rate data as a density with the matching beta distribution — PlotDistDensityBeta • WVPlots @@ -35,8 +35,8 @@ - - + + @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -120,13 +120,13 @@
-

Compares empirical data to a beta distribution with the same mean and standard deviation.

+

Compares empirical rate data to a beta distribution with the same mean and standard deviation.

PlotDistDensityBeta(frm, xvar, title, ..., curve_color = "lightgray",
@@ -177,10 +177,24 @@ 

Details

Examples

set.seed(52523) -d <- data.frame(wt=rbeta(100,shape1=1,shape2=0.5)) -PlotDistDensityBeta(d,'wt','example')
+N = 100 +pgray = 0.1 # rate of gray horses in the population +herd_size = round(runif(N, min=25, 50)) +ngray = rbinom(N, herd_size, pgray) +hdata = data.frame(n_gray=ngray, herd_size=herd_size) + +# observed rate of gray horses in each herd +hdata$rate_gray = with(hdata, ngray/herd_size) + +title = "Observed prevalence of gray horses in population" + +PlotDistDensityBeta(hdata, "rate_gray", title) + + ggplot2::geom_vline(xintercept = pgray, linetype=4, color="maroon") + + ggplot2::annotate("text", x=pgray+0.01, y=0.01, hjust="left", + label = paste("True prevalence =", pgray))
# no sd lines -PlotDistDensityBeta(d, 'wt', 'example', sd_color=NULL)
+PlotDistDensityBeta(hdata, "rate_gray", title, + sd_color=NULL)
-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/PlotDistDensityNormal.html b/docs/reference/PlotDistDensityNormal.html index 2025996..da5f5b7 100644 --- a/docs/reference/PlotDistDensityNormal.html +++ b/docs/reference/PlotDistDensityNormal.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -210,7 +210,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/PlotDistHistBeta-1.png b/docs/reference/PlotDistHistBeta-1.png index 6feb391..a35e072 100644 Binary files a/docs/reference/PlotDistHistBeta-1.png and b/docs/reference/PlotDistHistBeta-1.png differ diff --git a/docs/reference/PlotDistHistBeta-2.png b/docs/reference/PlotDistHistBeta-2.png index a5fa0b2..0b48e97 100644 Binary files a/docs/reference/PlotDistHistBeta-2.png and b/docs/reference/PlotDistHistBeta-2.png differ diff --git a/docs/reference/PlotDistHistBeta.html b/docs/reference/PlotDistHistBeta.html index b1a1f2f..4310ecf 100644 --- a/docs/reference/PlotDistHistBeta.html +++ b/docs/reference/PlotDistHistBeta.html @@ -6,7 +6,7 @@ -Plot distribution details as a histogram plus matching beta — PlotDistHistBeta • WVPlots +Plot empirical rate data as a histogram plus matching beta — PlotDistHistBeta • WVPlots @@ -35,8 +35,8 @@ - - + + @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -120,16 +120,16 @@
-

Compares empirical data to a beta distribution with the same mean and standard deviation.

+

Compares empirical rate data to a beta distribution with the same mean and standard deviation.

-
PlotDistHistBeta(frm, xvar, title, ..., binwidth = NULL, bins = 30,
+    
PlotDistHistBeta(frm, xvar, title, ..., bins = 30,
   hist_color = "darkgray", beta_color = "blue", mean_color = "blue",
   sd_color = "darkgray")
@@ -152,10 +152,6 @@

Arg ...

force later arguments to bind by name

- - binwidth -

passed to geom_histogram(). If passed in, overrides bins.

- bins

passed to geom_histogram(). Default: 30

@@ -191,10 +187,24 @@

Details

Examples

set.seed(52523) -d <- data.frame(wt=rbeta(100,shape1=0.5,shape2=0.5)) -PlotDistHistBeta(d,'wt','example')
+N = 100 +pgray = 0.1 # rate of gray horses in the population +herd_size = round(runif(N, min=25, 50)) +ngray = rbinom(N, herd_size, pgray) +hdata = data.frame(n_gray=ngray, herd_size=herd_size) + +# observed rate of gray horses in each herd +hdata$rate_gray = with(hdata, ngray/herd_size) + +title = "Observed prevalence of gray horses in population" + +PlotDistHistBeta(hdata, "rate_gray", title) + + ggplot2::geom_vline(xintercept = pgray, linetype=4, color="maroon") + + ggplot2::annotate("text", x=pgray+0.01, y=0.01, hjust="left", + label = paste("True prevalence =", pgray))
# no sd lines -PlotDistHistBeta(d,'wt','example', sd_color=NULL)
+PlotDistHistBeta(hdata, "rate_gray", title, + sd_color=NULL)
-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ROCPlot.html b/docs/reference/ROCPlot.html index 6da0edb..7dd0d7f 100644 --- a/docs/reference/ROCPlot.html +++ b/docs/reference/ROCPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -228,7 +228,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ROCPlotPair.html b/docs/reference/ROCPlotPair.html index 8fbdb07..b937176 100644 --- a/docs/reference/ROCPlotPair.html +++ b/docs/reference/ROCPlotPair.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -180,6 +180,10 @@

Arg parallelCluster

(optional) a cluster object created by package parallel or package snow.

+ + palette +

name of a brewer palette (NULL for ggplot2 default coloring)

+

Details

@@ -225,7 +229,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ROCPlotPair2.html b/docs/reference/ROCPlotPair2.html index b43874c..4c02c6d 100644 --- a/docs/reference/ROCPlotPair2.html +++ b/docs/reference/ROCPlotPair2.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -250,7 +250,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ScatterBoxPlot.html b/docs/reference/ScatterBoxPlot.html index 1e36685..b909ff0 100644 --- a/docs/reference/ScatterBoxPlot.html +++ b/docs/reference/ScatterBoxPlot.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -211,7 +211,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ScatterBoxPlotH.html b/docs/reference/ScatterBoxPlotH.html index a7381e9..7977b44 100644 --- a/docs/reference/ScatterBoxPlotH.html +++ b/docs/reference/ScatterBoxPlotH.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -212,7 +212,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ScatterHist.html b/docs/reference/ScatterHist.html index 59f3dbf..7316ee5 100644 --- a/docs/reference/ScatterHist.html +++ b/docs/reference/ScatterHist.html @@ -71,7 +71,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -289,7 +289,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ScatterHistC.html b/docs/reference/ScatterHistC.html index 54c7b3b..f02ed3e 100644 --- a/docs/reference/ScatterHistC.html +++ b/docs/reference/ScatterHistC.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -217,7 +217,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ScatterHistN.html b/docs/reference/ScatterHistN.html index 2b812c9..4583590 100644 --- a/docs/reference/ScatterHistN.html +++ b/docs/reference/ScatterHistN.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -218,7 +218,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ShadedDensity.html b/docs/reference/ShadedDensity.html index 71a0a66..02cbaef 100644 --- a/docs/reference/ShadedDensity.html +++ b/docs/reference/ShadedDensity.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -205,7 +205,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ShadedDensityCenter.html b/docs/reference/ShadedDensityCenter.html index 2403a0a..10b0d78 100644 --- a/docs/reference/ShadedDensityCenter.html +++ b/docs/reference/ShadedDensityCenter.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -200,7 +200,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ShadowHist.html b/docs/reference/ShadowHist.html index 0c424e9..bd4cdd6 100644 --- a/docs/reference/ShadowHist.html +++ b/docs/reference/ShadowHist.html @@ -71,7 +71,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -230,7 +230,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/ShadowPlot.html b/docs/reference/ShadowPlot.html index 99117b6..f8bb062 100644 --- a/docs/reference/ShadowPlot.html +++ b/docs/reference/ShadowPlot.html @@ -71,7 +71,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -221,7 +221,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/WVPlots.html b/docs/reference/WVPlots.html index af96faa..a76bc4a 100644 --- a/docs/reference/WVPlots.html +++ b/docs/reference/WVPlots.html @@ -73,7 +73,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -165,7 +165,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/index.html b/docs/reference/index.html index ab6c42f..0578c2e 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -67,7 +67,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -228,6 +228,12 @@

PlotDistCountBinomial()

+ +

Plot count data with a theoretical binomial

+ +

PlotDistCountNormal()

@@ -237,7 +243,7 @@

PlotDistDensityBeta()

-

Plot an empirical density with the matching beta distribution

+

Plot empirical rate data as a density with the matching beta distribution

@@ -249,7 +255,7 @@

PlotDistHistBeta()

-

Plot distribution details as a histogram plus matching beta

+

Plot empirical rate data as a histogram plus matching beta

@@ -372,7 +378,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/plot_Keras_fit_trajectory.html b/docs/reference/plot_Keras_fit_trajectory.html index 184a7bd..617e2bf 100644 --- a/docs/reference/plot_Keras_fit_trajectory.html +++ b/docs/reference/plot_Keras_fit_trajectory.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -231,8 +231,7 @@

Examp plt <- plot_Keras_fit_trajectory( d, - title = "model performance by epoch, dataset, and measure") - + title = "model performance by epoch, dataset, and measure")
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
suppressWarnings(print(plt)) # too few points for loess
@@ -256,7 +255,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/plot_fit_trajectory.html b/docs/reference/plot_fit_trajectory.html index bacd17e..8fb8b0e 100644 --- a/docs/reference/plot_fit_trajectory.html +++ b/docs/reference/plot_fit_trajectory.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -230,8 +230,7 @@

Examp title = "model performance by epoch, dataset, and measure", epoch_name = "epoch", pick_metric = "minus binary cross entropy", - discount_rate = 0.1) - + discount_rate = 0.1)
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
#> Warning: Column 'rqdatatable_temp_one_col' does not exist to remove
suppressWarnings(print(plt)) # too few points for loess
@@ -255,7 +254,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/plotlyROC.html b/docs/reference/plotlyROC.html index 64eb24b..f99d294 100644 --- a/docs/reference/plotlyROC.html +++ b/docs/reference/plotlyROC.html @@ -69,7 +69,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -201,7 +201,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/reexports.html b/docs/reference/reexports.html index 882e6fa..0724934 100644 --- a/docs/reference/reexports.html +++ b/docs/reference/reexports.html @@ -74,7 +74,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -158,7 +158,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/docs/reference/run_WVPlots_tests.html b/docs/reference/run_WVPlots_tests.html index b56b3b6..97549fd 100644 --- a/docs/reference/run_WVPlots_tests.html +++ b/docs/reference/run_WVPlots_tests.html @@ -72,7 +72,7 @@ WVPlots - 1.1.2 + 1.2.0 @@ -213,7 +213,7 @@

Contents

-

Site built with pkgdown 1.4.0.

+

Site built with pkgdown 1.4.1.

diff --git a/extras/check_reverse_dependencies.md b/extras/check_reverse_dependencies.md index 58d7a1f..4c30dbb 100644 --- a/extras/check_reverse_dependencies.md +++ b/extras/check_reverse_dependencies.md @@ -8,13 +8,13 @@ package = "WVPlots" date() ``` - ## [1] "Wed Sep 11 16:24:59 2019" + ## [1] "Thu Oct 3 21:06:02 2019" ``` r packageVersion(package) ``` - ## [1] '1.1.2' + ## [1] '1.2.0' ``` r parallelCluster <- NULL @@ -26,14 +26,14 @@ orig_dir <- getwd() print(orig_dir) ``` - ## [1] "/Users/ninazumel/Documents/Projects/Win-Verse/WVPlots/extras" + ## [1] "/Users/johnmount/Documents/work/WVPlots.git/extras" ``` r setwd(td) print(td) ``` - ## [1] "/var/folders/3s/hyy8hf1s2d7gtmxds0w7kq_w0000gp/T//RtmpggaX1w" + ## [1] "/var/folders/7q/h_jp2vj131g5799gfnpzhdp80000gn/T//RtmpAkVWtC" ``` r options(repos = c(CRAN="https://cloud.r-project.org"))