Skip to content

Commit

Permalink
small edits
Browse files Browse the repository at this point in the history
  • Loading branch information
mgimond committed Jan 16, 2024
1 parent fe369ba commit 7c06c35
Show file tree
Hide file tree
Showing 26 changed files with 105 additions and 351 deletions.
11 changes: 7 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# tukeyedar 0.2.1
* Added the option to plot the density distribution alongside the Normal fit in `eda_normfit`.

# tukeyedar 0.2.0
* Added a Normal QQ plot option to `eda_qq`
* Added symmetrical Normal fit plot function `eda_normfit`
* Updated eda_boxls aesthetics
* Updated median polish diagnostic plot aesthetics
* Added a Normal QQ plot option to `eda_qq`.
* Added symmetrical Normal fit plot function `eda_normfit`.
* Updated eda_boxls aesthetics.
* Updated median polish diagnostic plot aesthetics.

# tukeyedar 0.1.1

Expand Down
54 changes: 27 additions & 27 deletions R/eda_normfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
#' @description \code{eda_normfit} generates a fitted Normal distribution to the
#' data with the option to compare it to a density distribution.
#'
#' @param dat Vector of values or a dataframe.
#' @param dat Vector of values, or a dataframe.
#' @param x Column of values if \code{dat} is a dataframe, ignored otherwise.
#' @param grp Column of grouping variables if \code{dat} is a dataframe, ignored
#' otherwise.
#' @param p Power transformation to apply to both sets of values.
#' @param p Power transformation to apply to all values.
#' @param tukey Boolean determining if a Tukey transformation should be adopted
#' (FALSE adopts a Box-Cox transformation).
#' @param show.par Boolean determining if power transformation should be
#' displayed in the plot's upper-right corner.
#' (\code{TRUE}) or if a Box-Cox transformation should be adopted (\code{FALSE}).
#' @param show.par Boolean determining if the power transformation used with the
#' data should be displayed in the plot's upper-right corner.
#' @param sq Boolean determining if the plot should be square.
#' @param inner Fraction of values that should be captured by the inner color
#' band of the normal and density plots. Defaults to 0.6826 (inner 68% of
#' band of the normal and density plots. Defaults to 0.6826 (inner 68\% of
#' values).
#' @param dens Boolean determining if the density plot should displayed
#' alongside the normal fit plot.
#' @param bw Bandwidth parameter passed to the built-in \code{density} function.
#' @param kernel Kernel parameter passed to the built-in \code{density}
#' @param dens Boolean determining if the density plot should be displayed
#' alongside the Normal fit plot.
#' @param bw Bandwidth parameter passed to the \code{density()} function.
#' @param kernel Kernel parameter passed to the \code{density()}
#' function.
#' @param pch Point symbol type.
#' @param size Point side.
Expand All @@ -31,13 +31,14 @@
#' @param p.col Color for point symbol.
#' @param p.fill Point fill color passed to \code{bg} (Only used for \code{pch}
#' ranging from 21-25).
#' @param grey Grey level to apply to plot elements (0 to 1 with 1 = black).
#' @param grey Grey level to apply to plot elements such as axes, labels, etc...
#' (0 to 1 with 1 = black).
#' @param col.ends Fill color for ends of the Normal distribution.
#' @param col.mid Fill color for middle band of the Normal distribution.
#' @param col.ends.dens Fill color for ends of the density distribution.
#' @param col.mid.dens Fill color for middle band of the density distribution.
#' @param offset A value (in x-axis units) that defines the gap between left and
#' right side plots. Ignored if \code{dens} is \code{TRUE}.
#' right side plots. Ignored if \code{dens} is \code{FALSE}.
#' @param tsize Size of plot title.
#' @param xlab X variable label.
#' @param ylab Y variable label.
Expand All @@ -54,30 +55,29 @@
#' The plots have two fill colors: one for the inner band and the other for
#' the outer band. The inner band shows the area of the curve that encompasses
#' the desired fraction of values defined by \code{inner}. By default, this
#' value is 0.6826, or 68.26 percent (this is roughly the percentage of values
#' value is 0.6826, or 68.26\% (this is roughly the percentage of values
#' covered by +/- 1 standard deviations of a Normal distribution). For the
#' Normal fit plot, the range is computed from the theoretical Normal and not
#' from the actual values. For the density plot, the range is computed from
#' the actual values. By default, the colors are inverted between the Normal
#' curve and the density curve. If the density plot is not drawn, then the
#' Normal plot colors are identical about the vertical axis. \cr
#' the actual values. \cr
#' \cr
#' If a density plot is desired, \code{dens = TRUE}, a gap (defined by
#' \code{offset}) is created between the left side density plot and the right
#' side Normal fit plot. Points showing the location of values on the
#' y-axis are also added to help view their distribution relative to the
#' density and Normal fit curves. This function makes use of the built-in
#' \code{density} function. As such, you can pass the \code{bw} and
#' \code{kernel} parameters as you would for the \code{density} function.\cr
#' side Normal fit plot. This function makes use of the built-in
#' \code{stats::density} function. As such, you can pass the \code{bw} and
#' \code{kernel} parameters as you would for the \code{density()} function.
#' Points showing the location of values along the y-axis are also added to
#' help view their distributions relative to the density and Normal fit
#' curves. \cr
#' \cr
#' Measures of centrality are computed differently for the Normal fit and
#' density plots. The mean is computed for the Normal fit plot and the median
#' is computed for density plot. These measures of centrality are shown as
#' is computed for the density plot. These measures of centrality are shown as
#' black horizontal lines in the plot.\cr
#' \cr
#' The areas under the density and Normal fit plots are scaled to their
#' peak values, respectively. So, the areas should not be compared between
#' both plots.
#' both distributions.
#'
#'
#' @seealso \code{\link[stats]{density}}
Expand All @@ -98,8 +98,8 @@
#' # Limit the plot to just a Normal fit
#' eda_normfit(x, dens = FALSE)
#'
#' # The inner band's range can be modified. Here, we view the inter-quartile
#' # range, +/- 1 standard deviation range and the inner 95% range)
#' # The inner band's range can be modified. Here, we view the interquartile
#' # range, the +/- 1 standard deviation range and the inner 95% range)
#' OP <- par(mfrow = c(1,3))
#' invisible(sapply(c(0.5, 0.6826, 0.95),
#' function(prop) eda_normfit(x, inner = prop, tsize = 1,
Expand Down Expand Up @@ -153,7 +153,7 @@ eda_normfit <- function(dat, x=NULL, grp=NULL, p = 1, tukey = FALSE,
pch = 16, size = 0.8, alpha = 0.3, p.col = "grey50",
p.fill = "grey80",grey = 0.7,
col.ends = "grey90", col.mid = "#EBC89B",
col.ends.dens = "#EBC89B" , col.mid.dens = "grey90",
col.ends.dens = "grey90" , col.mid.dens = "#EBC89B",
offset = 0.02, tsize=1.5,
xlab = NULL, ylab = NULL, ...){

Expand Down Expand Up @@ -254,7 +254,7 @@ eda_normfit <- function(dat, x=NULL, grp=NULL, p = 1, tukey = FALSE,

# Create list of density distributions by group
out2 <- lapply(split(x, grp), function(x)
{dnsty <- density(x, n=120, bw = bw, kernel = kernel)
{dnsty <- stats::density(x, n=120, bw = bw, kernel = kernel)
densx <- dnsty$x
densy <- dnsty$y
data.frame(densx,densy)})
Expand Down
250 changes: 0 additions & 250 deletions R/eda_normfit.R.backup

This file was deleted.

Loading

0 comments on commit 7c06c35

Please sign in to comment.