Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke authored Oct 4, 2024
2 parents 2395bbd + 19d846b commit 3fff963
Show file tree
Hide file tree
Showing 31 changed files with 156 additions and 87 deletions.
23 changes: 17 additions & 6 deletions .lintr
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
linters: with_defaults(object_name_linter = NULL,
object_length_linter(40),
commented_code_linter = NULL,
object_usage_linter = NULL,
line_length_linter(120),
cyclocomp_linter = cyclocomp_linter(20))
linters: linters_with_defaults(
absolute_path_linter = NULL,
commented_code_linter = NULL,
cyclocomp_linter = cyclocomp_linter(25),
extraction_operator_linter = NULL,
implicit_integer_linter = NULL,
line_length_linter(120),
namespace_linter = NULL,
nonportable_path_linter = NULL,
object_name_linter = NULL,
object_length_linter(50),
object_usage_linter = NULL,
todo_comment_linter = NULL,
undesirable_function_linter(c("mapply" = NA, "sapply" = NA, "setwd" = NA)),
undesirable_operator_linter = NULL,
defaults = linters_with_tags(tags = NULL)
)
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ Package: sjPlot
Type: Package
Encoding: UTF-8
Title: Data Visualization for Statistics in Social Science
Version: 2.8.13.1
Version: 2.8.16.2
Authors@R: c(
person("Daniel", "Lüdecke", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-8895-3206")),
person("Alexander", "Bartel", role = "ctb", comment = c(ORCID = "0000-0002-1280-6138")),
person("Carsten", "Schwemmer", email = "[email protected]", role = "ctb"),
person(given = "Chuck", family = "Powell", role = "ctb", email = "[email protected]", comment = c(ORCID = "0000-0002-3606-2188")),
person(given = "Chuck", family = "Powell", role = "ctb", email = "[email protected]", comment = c(ORCID = "0000-0002-3606-2188")),
person(given = "Amir", family = "Djalovski", role = "ctb", email = "[email protected]"),
person(given = "Johannes", family = "Titz", role = "ctb", email = "[email protected]", comment = c(ORCID = "0000-0002-1102-5719")))
Maintainer: Daniel Lüdecke <[email protected]>
Description: Collection of plotting and table output functions for data
visualization. Results of various statistical analyses (that are commonly used
in social sciences) can be visualized using this package, including simple and
cross tabulated frequencies, histograms, box plots, (generalized) linear models,
mixed effects models, principal component analysis and correlation matrices,
cluster analyses, scatter plots, stacked scales, effects plots of regression
mixed effects models, principal component analysis and correlation matrices,
cluster analyses, scatter plots, stacked scales, effects plots of regression
models (including interaction terms) and much more. This package supports
labelled data.
License: GPL-3
Expand All @@ -30,7 +30,6 @@ Imports:
bayestestR,
datawizard,
dplyr,
effectsize,
ggeffects,
ggplot2 (>= 3.2.0),
knitr,
Expand All @@ -52,6 +51,7 @@ Suggests:
clubSandwich,
cluster,
cowplot,
effects,
haven,
GPArotation,
ggrepel,
Expand All @@ -71,5 +71,5 @@ Suggests:
testthat
URL: https://strengejacke.github.io/sjPlot/
BugReports: https://github.com/strengejacke/sjPlot/issues
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
VignetteBuilder: knitr
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ importFrom(sjstats,cramer)
importFrom(sjstats,crosstable_statistics)
importFrom(sjstats,phi)
importFrom(sjstats,table_values)
importFrom(sjstats,weighted_sd)
importFrom(stats,aov)
importFrom(stats,binomial)
importFrom(stats,chisq.test)
Expand Down
35 changes: 28 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# sjPlot 2.8.17

## Bug fixes

* Fixed issues with renamed arguments in upstream package *ggeffects*.

# sjPlot 2.8.15

* Minor fix in vignettes.

# sjPlot 2.8.14

* `tab_model()`, `plot_model()` and `plot_models()` get a `std.response` argument,
to include or exclude the response variable from standardization.

## Bug fixes

* Fixed test issues when no internet connection avaiable.

* Minor fixes and improvements.

# sjPlot 2.8.13

## Bug fixes
Expand All @@ -8,21 +29,21 @@

## General

* Minor changes to work properly with updates of upstream packages and
* Minor changes to work properly with updates of upstream packages and
various smaller bug fixes and improvements.

# sjPlot 2.8.11

## General

* Minor changes to work properly with updates of upstream packages and
* Minor changes to work properly with updates of upstream packages and
various smaller bug fixes and improvements.

# sjPlot 2.8.10

## General

* Minor changes to work properly with updates of downstream packages and
* Minor changes to work properly with updates of downstream packages and
various smaller bug fixes and improvements.

# sjPlot 2.8.9
Expand Down Expand Up @@ -191,7 +212,7 @@
## Bug fixes

* Fixed bug in `plot_stackfrq()` for data frames with many missing values.
* Fixed bug with sorting frequencies in `plot_frq()` when vector had more labels than values.
* Fixed bug with sorting frequencies in `plot_frq()` when vector had more labels than values.
* Fixed bug in `tab_model()` where `show.reflvl = TRUE` did not insert the reference category in first place, but in alphabetical order.

# sjPlot 2.7.1
Expand Down Expand Up @@ -255,7 +276,7 @@
* Argument `string.est` in `tab_model()` did not overwrite the default label for the estimate-column-header.
* Minor fix in `tab_model()` for mixed models that can't compute R2.
* Fix issue in `tab_model()` when printing robust standard errors and CI (i.e. when using arguments `vcov*`).
* The `plot_likert()` option `reverse.scale = TRUE` resulted in `values = "sum.inside"` being outside and the other way around. This is fixed now.
* The `plot_likert()` option `reverse.scale = TRUE` resulted in `values = "sum.inside"` being outside and the other way around. This is fixed now.
* `view_df()` mixed up labels and frequency values when value labels were present, but no such values were in the data.
* Argument `wrap.labels` in `plot_frq()` did not properly work for factor levels.
* Fix issue in `plot_models()` that stopped for some models.
Expand Down Expand Up @@ -324,7 +345,7 @@ Following functions are now defunct:
## Bug fixes

* `plot_model()` no longer automatically changes the plot-type to `"slope"` for models with only one predictor that is categorical and has more than two levels.
* `type = "eff"` and `type = "pred"` in `plot_model()` did not work when `terms` was not specified.
* `type = "eff"` and `type = "pred"` in `plot_model()` did not work when `terms` was not specified.
* If robust standard errors are requested in `tab_model()`, the confidence intervals and p-values are now re-calculated and adjusted based on the robust standard errors.
* `colors = "bw"` was not recognized correctly for `plot_model(..., type = "int")`.
* Fix issue in `sjp.frq()` with correct axis labels for non-labelled character vectors.
Expand Down
6 changes: 3 additions & 3 deletions R/helpfunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ get_dplyr_dot_data <- function(x, qs) {

# add annotations with table summary
# here we print out total N of cases, chi-square and significance of the table
print.table.summary <- function(baseplot,
modsum,
summary.pos = "r") {
.print.table.summary <- function(baseplot,
modsum,
summary.pos = "r") {
if (!is.null(modsum)) {
# add annotations with table summary
# here we print out total N of cases, chi-square and significance of the table
Expand Down
3 changes: 1 addition & 2 deletions R/plot_frq.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ utils::globalVariables("density")
#' normal.curve.size = 3, ylim = c(0,50))
#' }
#' @import ggplot2
#' @importFrom sjstats weighted_sd
#' @importFrom sjmisc group_labels group_var to_value frq
#' @importFrom sjlabelled set_labels drop_labels
#' @importFrom stats na.omit sd weighted.mean dnorm
Expand Down Expand Up @@ -387,7 +386,7 @@ plot_frq_helper <- function(
stddev <- stats::sd(var.cnt, na.rm = TRUE)
} else {
mittelwert <- stats::weighted.mean(var.cnt, weight.by, na.rm = TRUE)
stddev <- sjstats::weighted_sd(var.cnt, weights = weight.by)
stddev <- datawizard::weighted_sd(var.cnt, weights = weight.by)
}

# If we have boxplots, use different data frame structure
Expand Down
2 changes: 1 addition & 1 deletion R/plot_grpfrq.R
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ plot_grpfrq <- function(var.cnt,

# If we have bars or dot plots, we show
# Pearson's chi-square test results
baseplot <- print.table.summary(baseplot, modsum, summary.pos)
baseplot <- .print.table.summary(baseplot, modsum, summary.pos)

# prepare y-axis and
# show or hide y-axis-labels
Expand Down
8 changes: 8 additions & 0 deletions R/plot_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
#' @param order.terms Numeric vector, indicating in which order the coefficients
#' should be plotted. See examples in
#' \href{https://strengejacke.github.io/sjPlot/articles/plot_model_estimates.html}{this package-vignette}.
#' @param std.response Logical, whether the response variable will also be
#' standardized if standardized coefficients are requested. Setting both
#' \code{std.response = TRUE} and \code{show.std = TRUE} will behave as if
#' the complete data was standardized before fitting the model.
#' @param pred.type Character, only applies for \emph{Marginal Effects} plots
#' with mixed effects models. Indicates whether predicted values should be
#' conditioned on random effects (\code{pred.type = "re"}) or fixed effects
Expand Down Expand Up @@ -411,6 +415,7 @@
#'
#' @examples
#' # prepare data
#' if (requireNamespace("haven")) {
#' library(sjmisc)
#' data(efc)
#' efc <- to_factor(efc, c161sex, e42dep, c172code)
Expand All @@ -425,6 +430,7 @@
#' # keep only selected terms in the model: pos_v_4, the
#' # levels 3 and 4 of factor e42dep and levels 2 and 3 for c172code
#' plot_model(m, terms = c("pos_v_4", "e42dep [3,4]", "c172code [2,3]"))
#' }
#'
#' # multiple plots, as returned from "diagnostic"-plot type,
#' # can be arranged with 'plot_grid()'
Expand Down Expand Up @@ -517,6 +523,7 @@ plot_model <- function(model,
bpe.style = "line",
bpe.color = "white",
ci.style = c("whisker", "bar"),
std.response = TRUE,
...
) {

Expand Down Expand Up @@ -656,6 +663,7 @@ plot_model <- function(model,
vcov.args = vcov.args,
ci.style = ci.style,
p_adjust = p.adjust,
std.response = std.response,
...
)

Expand Down
6 changes: 4 additions & 2 deletions R/plot_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
plot_models <- function(...,
transform = NULL,
std.est = NULL,
std.response = TRUE,
rm.terms = NULL,
title = NULL,
m.labels = NULL,
Expand Down Expand Up @@ -156,8 +157,8 @@ plot_models <- function(...,


# check for standardization, only applies to linear models
if (!any(inherits(input_list[[1]], c("lm", "lmerMod", "lme"), which = TRUE) == 1))
std.est <- NULL
# if (!any(inherits(input_list[[1]], c("lm", "lmerMod", "lme"), which = TRUE) == 1))
# std.est <- NULL


if (!is.null(std.est)) {
Expand All @@ -182,6 +183,7 @@ plot_models <- function(...,
show.zeroinf = FALSE,
p.val = "wald",
standardize = std_method,
std.response = std.response,
bootstrap = FALSE,
iterations = 1000,
seed = NULL,
Expand Down
22 changes: 11 additions & 11 deletions R/plot_type_eff.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ plot_type_eff <- function(type,
dat <- ggeffects::ggpredict(
model = model,
terms = terms,
ci.lvl = ci.lvl,
ci_level = ci.lvl,
type = pred.type,
...
)
} else if (type == "emm") {
dat <- ggeffects::ggemmeans(
model = model,
terms = terms,
ci.lvl = ci.lvl,
ci_level = ci.lvl,
type = pred.type,
...
)
} else {
dat <- ggeffects::ggeffect(
model = model,
terms = terms,
ci.lvl = ci.lvl,
ci_level = ci.lvl,
...
)
}
Expand Down Expand Up @@ -82,20 +82,20 @@ plot_type_eff <- function(type,

p <- graphics::plot(
dat,
ci = !is.na(ci.lvl),
show_ci = !is.na(ci.lvl),
facets = facets,
rawdata = show.data,
show_data = show.data,
colors = geom.colors,
use.theme = FALSE,
use_theme = FALSE,
jitter = jitter,
case = case,
show.legend = show.legend,
dot.alpha = dot.alpha,
show_legend = show.legend,
dot_alpha = dot.alpha,
alpha = alpha,
dodge = dodge,
log.y = log.y,
dot.size = dot.size,
line.size = line.size
log_y = log.y,
dot_size = dot.size,
line_size = line.size
)


Expand Down
2 changes: 2 additions & 0 deletions R/plot_type_est.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ plot_type_est <- function(type,
vcov.args,
ci.style,
p_adjust,
std.response,
...) {

if (missing(facets)) facets <- TRUE
Expand Down Expand Up @@ -64,6 +65,7 @@ plot_type_est <- function(type,
iterations = 1000,
seed = NULL,
p_adjust = p_adjust,
std.response = std.response,
...
)

Expand Down
18 changes: 9 additions & 9 deletions R/plot_type_int.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ plot_type_int <- function(model,
dat <- ggeffects::ggpredict(
model = model,
terms = ia,
ci.lvl = ci.lvl,
ci_level = ci.lvl,
type = pred.type,
full.data = FALSE,
...
Expand Down Expand Up @@ -132,20 +132,20 @@ plot_type_int <- function(model,

p <- graphics::plot(
dat,
ci = !is.na(ci.lvl),
show_ci = !is.na(ci.lvl),
facets = facets,
rawdata = show.data,
show_data = show.data,
colors = geom.colors,
jitter = jitter,
use.theme = FALSE,
use_theme = FALSE,
case = case,
show.legend = show.legend,
dot.alpha = dot.alpha,
show_legend = show.legend,
dot_alpha = dot.alpha,
alpha = alpha,
dodge = dodge,
log.y = log.y,
dot.size = dot.size,
line.size = line.size
log_y = log.y,
dot_size = dot.size,
line_size = line.size
)

# set axis and plot titles
Expand Down
Loading

0 comments on commit 3fff963

Please sign in to comment.