Skip to content

Commit 66451ae

Browse files
authored
- added contributors, allowed themes to be used as closures, defined how the default theme should look like, previous default is now seminr_theme_old. (#201)
1 parent 98c8a43 commit 66451ae

File tree

10 files changed

+100
-36
lines changed

10 files changed

+100
-36
lines changed

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ Authors@R: c(person("Soumya", "Ray", email = "soumya.ray@gmail.com", role = c("a
88
person("André", "Calero Valdez", role = "aut", email = "andrecalerovaldez@gmail.com"),
99
person("Juan Manuel Velasquez", "Estrada", role = "ctb"),
1010
person("James", "Uanhoro", role = "ctb", email = "James.uanhoro@gmail.com"),
11-
person("Arturo Heynar Cano", "Bejar", role = "ctb", email = "arturocano997@gmail.com"),
1211
person("Johannes", "Nakayama", role = "ctb", email = "johannes.nakayama@rwth-aachen.de")
12+
person("Lilian", "Koyan", role = "ctb", email = "lilian.kojan@rwth-aachen.de"),
13+
person("Laura", "Burbach", role = "ctb", email = "laura.burbach@rwth-aachen.de"),
14+
person("Arturo Heynar", "Cano Bejar", role = "ctb", email = "arturocano997@gmail.com")
1315
)
1416
Description: A powerful, easy to syntax for specifying and estimating complex
1517
Structural Equation Models. Models can be estimated using Partial

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export(seminr_theme_create)
8181
export(seminr_theme_dark)
8282
export(seminr_theme_default)
8383
export(seminr_theme_get)
84-
export(seminr_theme_modern)
84+
export(seminr_theme_old)
8585
export(seminr_theme_set)
8686
export(seminr_theme_smart)
8787
export(set_last_seminr_plot)

R/plot_dot.R

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ query_install <- function(pkg_name = "DiagrammeR", failure_msg=""){
6767
"----------------------------------------------------------------------\n",
6868
"This function requires the ", pkg_name, " package.\n",
6969
"You can install it by calling: install.packages(\"", pkg_name, "\")\n",
70-
"Do you want to install ", pkg_name, " right now (Y/n)?"
70+
"Do you want to install ", pkg_name, " right now (Y/n)? "
7171
))
7272
if (x == "Y") {
7373
utils::install.packages(pkg_name)
@@ -563,7 +563,11 @@ dot_graph.pls_model <- function(model,
563563
if (is.null(theme)) {
564564
thm <- seminr_theme_get()
565565
} else {
566-
thm <- theme
566+
if (inherits(theme, "function")) {
567+
thm <- theme()
568+
} else {
569+
thm <- theme
570+
}
567571
}
568572

569573
if (thm$plot.title == "") {
@@ -1003,10 +1007,15 @@ extract_sm_edges <- function(model, theme, weights = 1) {
10031007
# for every path add an edge
10041008
for (i in 1:nrow(sm)) {
10051009

1006-
if ( !(sm[i,1] %in% colnames(model$rSquared))) {
1007-
letter <- gamma # when it is determined only by exogenous variables use gamma
1010+
# since one estimation technique is used the default is to used betas
1011+
if (theme$sm.edge.label.all_betas) {
1012+
letter <- beta
10081013
} else {
1009-
letter <- beta
1014+
if ( !(sm[i,1] %in% colnames(model$rSquared))) {
1015+
letter <- gamma # when it is determined only by exogenous variables use gamma
1016+
} else {
1017+
letter <- beta
1018+
}
10101019
}
10111020

10121021
# build label components

R/theme.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
#' @param sm.edge.label.fontsize Font size of the structural model edge labels.
6565
#' @param sm.edge.label.fontcolor Font color of the structural model edge labels.
6666
#' @param sm.edge.label.show Whether or not to show edge labels on structural model edges.
67+
#' @param sm.edge.label.all_betas Whether to label both endogenous and exogenous paths with a beta (default = TRUE).
6768
#' @param sm.edge.minlen Minimum length of the structural model edges.
6869
#' @param sm.edge.width_offset The minimal width of an edge of the structural model (default = 0.5).
6970
#' @param sm.edge.width_multiplier The multiplier for structural model edges (default = 5).
@@ -131,16 +132,17 @@ seminr_theme_create <- function(plot.title.fontsize = 24,
131132
sm.edge.label.fontsize = 9,
132133
sm.edge.label.fontcolor = "black",
133134
sm.edge.label.show = TRUE,
135+
sm.edge.label.all_betas = TRUE,
134136
sm.edge.minlen = NA_integer_,
135137
sm.edge.width_offset = 0.5,
136138
sm.edge.width_multiplier = 5,
137139
construct.reflective.shape = "ellipse",
138140
construct.reflective.arrow = "backward",
139141
construct.reflective.use_weights = FALSE,
140-
construct.compositeA.shape = "ellipse",
142+
construct.compositeA.shape = "hexagon",
141143
construct.compositeA.arrow = "backward",
142144
construct.compositeA.use_weights = FALSE,
143-
construct.compositeB.shape = "ellipse",
145+
construct.compositeB.shape = "hexagon",
144146
construct.compositeB.arrow = "forward",
145147
construct.compositeB.use_weights = TRUE,
146148
manifest.reflective.shape = "box",
@@ -237,6 +239,7 @@ seminr_theme_create <- function(plot.title.fontsize = 24,
237239
sm.edge.label.fontsize = sm.edge.label.fontsize,
238240
sm.edge.label.fontcolor = sm.edge.label.fontcolor,
239241
sm.edge.label.show = sm.edge.label.show,
242+
sm.edge.label.all_betas = sm.edge.label.all_betas,
240243
sm.edge.boot.show_t_value = sm.edge.boot.show_t_value,
241244
sm.edge.boot.show_p_value = sm.edge.boot.show_p_value,
242245
sm.edge.boot.show_p_stars = sm.edge.boot.show_p_stars,

R/theme_defaults.R

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

3-
#' The theme function for a basic b/w theme
3+
#' A theme function for a basic b/w theme
44
#'
55
#' @param plot.title.fontsize Title font size
66
#' @param sm.node.label.fontsize Font size for constructs
@@ -12,7 +12,7 @@
1212
#' @export
1313
#'
1414
# @examples
15-
seminr_theme_default <- function(plot.title.fontsize = 24,
15+
seminr_theme_old <- function(plot.title.fontsize = 24,
1616
mm.node.label.fontsize = 8,
1717
sm.node.label.fontsize = 12,
1818
mm.edge.label.fontsize = 7,
@@ -23,7 +23,19 @@ seminr_theme_default <- function(plot.title.fontsize = 24,
2323
mm.node.label.fontsize = mm.node.label.fontsize,
2424
sm.node.label.fontsize = sm.node.label.fontsize,
2525
mm.edge.label.fontsize = mm.edge.label.fontsize,
26-
sm.edge.label.fontsize = sm.edge.label.fontsize
26+
sm.edge.label.fontsize = sm.edge.label.fontsize,
27+
construct.reflective.shape = "ellipse",
28+
construct.reflective.arrow = "backward",
29+
construct.reflective.use_weights = FALSE,
30+
construct.compositeA.shape = "ellipse",
31+
construct.compositeA.arrow = "backward",
32+
construct.compositeA.use_weights = FALSE,
33+
construct.compositeB.shape = "ellipse",
34+
construct.compositeB.arrow = "forward",
35+
construct.compositeB.use_weights = TRUE,
36+
manifest.reflective.shape = "box",
37+
manifest.compositeA.shape = "box",
38+
manifest.compositeB.shape = "box"
2739
)
2840
}
2941

@@ -56,23 +68,36 @@ seminr_theme_smart <- function(plot.title.fontsize = 24,
5668
}
5769

5870

59-
#' The theme function for a modern approach of visualizing PLS models in b/w
71+
#' A theme function for a modern approach of visualizing PLS models in b/w
6072
#'
6173
#' @param plot.title.fontsize Title font size
6274
#' @param sm.node.label.fontsize Font size for constructs
6375
#' @param mm.node.label.fontsize Font size for measurement variables
6476
#' @param sm.edge.label.fontsize Font size for path edges
6577
#' @param mm.edge.label.fontsize Font size for measurement model edges
78+
#' @param construct.reflective.shape Shape of reflective constructs
79+
#' @param construct.compositeA.shape Shape of composite constructs mode A
80+
#' @param construct.compositeB.shape Shape of composite constructs mode B
81+
#' @param construct.reflective.arrow Direction of arrows of reflective constructs
82+
#' @param construct.compositeA.arrow Direction of arrows of composite constructs mode A
83+
#' @param construct.compositeB.arrow Direction of arrows of composite constructs mode B
84+
#' @param ... Other parameters for the seminr_theme_create function
6685
#'
6786
#' @return a theme object
6887
#' @export
6988
#'
7089
# @examples
71-
seminr_theme_modern <- function(plot.title.fontsize = 24,
90+
seminr_theme_default <- function(plot.title.fontsize = 24,
7291
mm.node.label.fontsize = 8,
7392
sm.node.label.fontsize = 12,
7493
mm.edge.label.fontsize = 7,
75-
sm.edge.label.fontsize = 9
94+
sm.edge.label.fontsize = 9,
95+
construct.reflective.shape = "ellipse",
96+
construct.compositeA.shape = "hexagon",
97+
construct.compositeB.shape = "hexagon",
98+
construct.reflective.arrow = "backward",
99+
construct.compositeA.arrow = "backward",
100+
construct.compositeB.arrow = "forward", ...
76101
){
77102

78103
# TODO: remove arrows for composite
@@ -82,12 +107,13 @@ seminr_theme_modern <- function(plot.title.fontsize = 24,
82107
sm.node.label.fontsize = sm.node.label.fontsize,
83108
mm.edge.label.fontsize = mm.edge.label.fontsize,
84109
sm.edge.label.fontsize = sm.edge.label.fontsize,
85-
construct.reflective.shape = "ellipse",
86-
construct.compositeA.shape = "hexagon",
87-
construct.compositeB.shape = "ellipse",
88-
construct.reflective.arrow = "backward",
89-
construct.compositeA.arrow = "none",
90-
construct.compositeB.arrow = "forward"
110+
construct.reflective.shape = construct.reflective.shape,
111+
construct.compositeA.shape = construct.compositeA.shape,
112+
construct.compositeB.shape = construct.compositeB.shape,
113+
construct.reflective.arrow = construct.reflective.arrow,
114+
construct.compositeA.arrow = construct.compositeA.arrow,
115+
construct.compositeB.arrow = construct.compositeB.arrow,
116+
...
91117
)
92118
}
93119

man/figures/model.png

2.88 KB
Loading

man/figures/model2.png

-5.56 KB
Loading

man/seminr_theme_create.Rd

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/seminr_theme_default.Rd

Lines changed: 29 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)