Skip to content

Commit

Permalink
release 2.3.1 on CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
sjPlot committed Mar 5, 2017
1 parent dcda7c4 commit 8ea8492
Show file tree
Hide file tree
Showing 81 changed files with 2,353 additions and 2,481 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Package: sjPlot
Type: Package
Encoding: UTF-8
Title: Data Visualization for Statistics in Social Science
Version: 2.3.0.9001
Date: 2017-02-14
Version: 2.3.1
Date: 2017-03-04
Authors@R: c(
person("Daniel", "Lüdecke", email = "d.luedecke@uke.de", role = c("aut", "cre")),
person("Carsten", "Schwemmer", email = "carsten.schwemmer@uni-bamberg.de", role = "ctb")
Expand Down Expand Up @@ -39,7 +39,7 @@ Imports:
purrr,
scales,
sjmisc (>= 2.3.0),
sjstats (>= 0.8.0.9000),
sjstats (>= 0.8.0),
tibble (>= 1.2.0),
tidyr (>= 0.6.0)
Suggests:
Expand Down
4 changes: 2 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version 2.3.0.9000
Version 2.3.1
-----------------------------------------------------------------------------
General:
* All `sjt`-functions can now be directly integrated into knitr-code-chunks, because sjPlot exports a knitr-print-method (see `vignette("sjtbasic", "sjPlot")`).
Expand All @@ -15,7 +15,7 @@ Changes to functions:
* Argument `emph.p` for printing tables of regression models now defaults to `FALSE`.

Bug fixes:
* Fixed bug in `sjt.frq()` for variables with many missign values and labelled values that did not occur on that variable.
* Fixed bug in `sjt.frq()` for variables with many missing values and labelled values that did not occur on that variable.
* Argument `value.labels` had no effect for `sjt.frq()`.
* Automatic label detection in `sjt.grpmean()` sometimes not worked for factors without variable labels.
* `sjp.glm()` used "Odds Ratios" as default title for y-axis when plotting marginal effects. Fixed, now y-axis is correctly labelled.
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sjPlot 2.3.0.9000
# sjPlot 2.3.1

## General

Expand All @@ -18,7 +18,7 @@

## Bug fixes

* Fixed bug in `sjt.frq()` for variables with many missign values and labelled values that did not occur on that variable.
* Fixed bug in `sjt.frq()` for variables with many missing values and labelled values that did not occur on that variable.
* Argument `value.labels` had no effect for `sjt.frq()`.
* Automatic label detection in `sjt.grpmean()` sometimes not worked for factors without variable labels.
* `sjp.glm()` used _Odds Ratios_ as default title for y-axis when plotting marginal effects. Fixed, now y-axis is correctly labelled.
Expand Down
48 changes: 24 additions & 24 deletions R/set_theme.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' @title Set default theme for sjp-functions
#' @name set_theme
#'
#'
#' @description Set default theme for sjp-functions.
#'
#'
#' @param theme Name of a pre-set theme. May be one of:
#' \describe{
#' \item{\code{"blank"}}{a theme with no grids and axes.}
Expand All @@ -12,35 +12,35 @@
#' \item{\code{"scatter"}}{a theme for scatter plots in 539-theme-style.}
#' \item{\code{"538w"}, \code{"539w"}, \code{"scatterw"} and \code{"forestw"}}{for themes as described above, however all with white backgrounds.}
#' }
#' @param ... other arguments passed down to \code{\link{sjp.setTheme}}.
#'
#' @param ... Other arguments passed down to \code{\link{sjp.setTheme}}.
#'
#' @return The customized theme object.
#'
#'
#' @seealso \href{http://www.strengejacke.de/sjPlot/custplot/}{sjPlot manual: customize plot appearance}
#'
#'
#' @references \itemize{
#' \item \href{http://zevross.com/blog/2014/08/04/beautiful-plotting-in-r-a-ggplot2-cheatsheet-3/}{Beautiful plotting in R: A ggplot2 cheatsheet}
#' \item \href{http://minimaxir.com/2015/02/ggplot-tutorial/}{An Introduction on How to Make Beautiful Charts With R and ggplot2}
#' }
#'
#'
#' @examples
#' library(sjmisc)
#' data(efc)
#'
#'
#' # of the ggplot base theme
#' set_theme("539")
#' sjp.xtab(efc$e42dep, efc$e16sex)
#'
#'
#' @import ggplot2
#' @importFrom scales brewer_pal grey_pal
#' @importFrom dplyr case_when
#' @export
set_theme <- function(theme = c("forest", "538", "539", "scatter", "forestw",
"538w", "539w", "scatterw", "blank"),
...) {

theme <- match.arg(theme)

if (theme == "blank") {
return(sjp.setTheme(
base = theme_classic(),
Expand All @@ -51,12 +51,12 @@ set_theme <- function(theme = c("forest", "538", "539", "scatter", "forestw",
...
))
}

g.palette <- scales::brewer_pal(palette = "Greys")(9)

col.ind <- dplyr::case_when(
theme == "538" ~ 2,
theme == "539" ~ 2,
theme == "538" ~ 2,
theme == "539" ~ 2,
theme == "forest" ~ 2,
theme == "scatter" ~ 2,
theme == "539w" ~ 1,
Expand All @@ -70,36 +70,36 @@ set_theme <- function(theme = c("forest", "538", "539", "scatter", "forestw",
theme %in% c("forest", "forestw") ~ col.ind,
TRUE ~ 4
)

axis.linecolor <- dplyr::case_when(
theme == "538" ~ g.palette[col.ind],
theme == "538" ~ g.palette[col.ind],
theme == "538w" ~ g.palette[col.ind],
TRUE ~ g.palette[5]
)

axis.linecolor.x <- dplyr::case_when(
theme == "538" ~ g.palette[col.ind],
theme == "538" ~ g.palette[col.ind],
theme == "538w" ~ g.palette[col.ind],
TRUE ~ g.palette[5]
)

axis.linecolor.y <- dplyr::case_when(
theme == "scatter" ~ g.palette[5],
theme == "scatter" ~ g.palette[5],
theme == "scatterw" ~ g.palette[5],
TRUE ~ g.palette[col.ind]
)

panel.gridcol.x <- dplyr::case_when(
theme %in% c("539", "539w", "538", "538w", "forest", "forestw") ~ g.palette[col.ind],
TRUE ~ g.palette[4]
)
)

if (theme %in% c("scatter", "scatterw")) {
panel.major.linetype <- panel.minor.linetype <- 2
} else {
panel.major.linetype <- panel.minor.linetype <- NULL
}

return(sjp.setTheme(
base = ggplot2::theme_bw(),
# plot
Expand Down
52 changes: 26 additions & 26 deletions R/sjPlotAnova.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ utils::globalVariables(c("pv", "xv"))

#' @title Plot One-Way-Anova tables
#' @name sjp.aov1
#'
#' @description Plot One-Way-Anova table sum of squares (SS) of each factor level (group)
#' against the dependent variable. The SS of the factor variable against the
#'
#' @description Plot One-Way-Anova table sum of squares (SS) of each factor level (group)
#' against the dependent variable. The SS of the factor variable against the
#' dependent variable (variance within and between groups) is printed to
#' the model summary.
#'
#'
#' @seealso \code{\link{sjt.grpmean}}
#'
#' @param var.dep dependent variable. Will be used with following formula:
#'
#' @param var.dep Dependent variable. Will be used with following formula:
#' \code{aov(var.dep ~ var.grp)}
#' @param var.grp factor with the cross-classifying variable, where \code{var.dep}
#' @param var.grp Factor with the cross-classifying variable, where \code{var.dep}
#' is grouped into the categories represented by \code{var.grp}.
#' @param meansums logical, if \code{TRUE}, the values reported are the true group mean values (see also \code{\link{sjt.grpmean}}).
#' @param meansums Logical, if \code{TRUE}, the values reported are the true group mean values (see also \code{\link{sjt.grpmean}}).
#' If \code{FALSE} (default), the values are reported in the standard way, i.e. the values indicate the difference of
#' the group mean in relation to the intercept (reference group).
#' @param string.interc string that indicates the reference group (intercept), that is appended to
#' @param string.interc Character vector that indicates the reference group (intercept), that is appended to
#' the value label of the grouping variable. Default is \code{"(Intercept)"}.
#'
#'
#' @inheritParams sjp.grpfrq
#' @inheritParams sjp.lm
#' @inheritParams sjp.glmer
#' @inheritParams sjp.xtab
#' @inheritParams sjp.gpt
#'
#'
#' @return (Insisibily) returns the ggplot-object with the complete plot (\code{plot}) as well as the data frame that
#' was used for setting up the ggplot-object (\code{df}).
#'
#'
#' @examples
#' library(sjmisc)
#' data(efc)
#' # note: "var.grp" does not need to be a factor.
#' # coercion to factor is done by the function
#' sjp.aov1(efc$c12hour, efc$e42dep)
#'
#'
#'
#'
#' @import ggplot2
#' @importFrom sjmisc get_label get_labels trim word_wrap to_value
#' @importFrom stats confint aov summary.lm
Expand Down Expand Up @@ -72,7 +72,7 @@ sjp.aov1 <- function(var.dep,
# --------------------------------------------------------
# try to automatically set labels is not passed as parameter
# --------------------------------------------------------
if (is.null(axis.labels)) axis.labels <- sjmisc::get_labels(var.grp,
if (is.null(axis.labels)) axis.labels <- sjmisc::get_labels(var.grp,
attr.only = F,
include.values = NULL,
include.non.labelled = T)
Expand All @@ -86,8 +86,8 @@ sjp.aov1 <- function(var.dep,
# remove titles if empty
# --------------------------------------------------------
if (!is.null(axis.labels) && axis.labels == "") axis.labels <- NULL
if (!is.null(axis.title) && axis.title == "") axis.title <- NULL
if (!is.null(title) && title == "") title <- NULL
if (!is.null(axis.title) && axis.title == "") axis.title <- NULL
if (!is.null(title) && title == "") title <- NULL
# --------------------------------------------------------
# unlist labels
# --------------------------------------------------------
Expand Down Expand Up @@ -179,7 +179,7 @@ sjp.aov1 <- function(var.dep,
if (show.p) {
for (i in seq_len(length(means.p))) {
ps[i] <- sjmisc::trim(paste(ps[i], get_p_stars(means.p[i])))
}
}
}
# --------------------------------------------------------
# check whether order of category items should be reversed
Expand Down Expand Up @@ -229,7 +229,7 @@ sjp.aov1 <- function(var.dep,
minval <- min(df$lower)
if (maxval > 0)
limfac <- ifelse(abs(maxval) < 5, 5, 10)
else
else
limfac <- ifelse(abs(minval) < 5, 5, 10)
upper_lim <- ifelse(maxval == 0, 0, limfac * ceiling((maxval + 1) / limfac))
lower_lim <- ifelse(minval == 0, 0, limfac * floor(minval / limfac))
Expand All @@ -245,9 +245,9 @@ sjp.aov1 <- function(var.dep,
# --------------------------------------------------------
# Set up plot padding (margins inside diagram)
# --------------------------------------------------------
scaley <- scale_y_continuous(limits = c(lower_lim, upper_lim),
breaks = ticks,
labels = ticks)
scaley <- scale_y_continuous(limits = c(lower_lim, upper_lim),
breaks = ticks,
labels = ticks)
# --------------------------------------------------------
# Start plot here!
# --------------------------------------------------------
Expand All @@ -256,7 +256,7 @@ sjp.aov1 <- function(var.dep,
geom_point(size = geom.size, colour = df$geocol) +
# and error bar
geom_errorbar(aes(ymin = lower, ymax = upper), colour = df$geocol, width = 0) +
# Print p-values. With vertical adjustment, so
# Print p-values. With vertical adjustment, so
# they don't overlap with the errorbars
geom_text(aes(label = pv, y = means), nudge_x = y.offset, show.legend = FALSE) +
# set y-scale-limits, breaks and tick labels
Expand All @@ -270,8 +270,8 @@ sjp.aov1 <- function(var.dep,
if (show.summary) {
# add annotations with model summary
# annotations include intercept-value and model's r-square
anovaplot <- anovaplot +
annotate("text", label = modsum, parse = TRUE, x = -Inf, y = Inf,
anovaplot <- anovaplot +
annotate("text", label = modsum, parse = TRUE, x = -Inf, y = Inf,
hjust = "right", vjust = "bottom")
}
# ---------------------------------------------------------
Expand All @@ -282,7 +282,7 @@ sjp.aov1 <- function(var.dep,
# set proper column names
# -------------------------------------
df <- tibble::rownames_to_column(df)
colnames(df) <- c("term", "estimate", "conf.low", "conf.high",
colnames(df) <- c("term", "estimate", "conf.low", "conf.high",
"p.value", "p.string", "xpos", "geom.color")
# -------------------------------------
# return results
Expand Down
Loading

0 comments on commit 8ea8492

Please sign in to comment.