Skip to content

Commit d984d9a

Browse files
committed
use pkg conditionally
1 parent f44a5c4 commit d984d9a

12 files changed

+87
-86
lines changed

R/model_parameters.gam.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
#'
1313
#' @examples
1414
#' library(parameters)
15-
#' library(mgcv)
16-
#'
17-
#' dat <- gamSim(1, n = 400, dist = "normal", scale = 2)
18-
#' model <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)
19-
#' model_parameters(model)
15+
#' if (require("mgcv")) {
16+
#' dat <- gamSim(1, n = 400, dist = "normal", scale = 2)
17+
#' model <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)
18+
#' model_parameters(model)
19+
#' }
2020
#' @export
2121
model_parameters.gam <- function(model, ci = .95, bootstrap = FALSE, iterations = 1000, standardize = NULL, exponentiate = FALSE, robust = FALSE, p_adjust = NULL, ...) {
2222
# Processing

R/model_parameters.psych.R

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,39 @@
1717
#'
1818
#' @examples
1919
#' library(parameters)
20-
#' library(psych)
20+
#' if (require("psych")) {
21+
#' # Principal Component Analysis (PCA) ---------
22+
#' pca <- psych::principal(attitude)
23+
#' model_parameters(pca)
2124
#'
22-
#' # Principal Component Analysis (PCA) ---------
23-
#' pca <- psych::principal(attitude)
24-
#' model_parameters(pca)
25+
#' pca <- psych::principal(attitude, nfactors = 3, rotate = "none")
26+
#' model_parameters(pca, sort = TRUE, threshold = 0.2)
2527
#'
26-
#' pca <- psych::principal(attitude, nfactors = 3, rotate = "none")
27-
#' model_parameters(pca, sort = TRUE, threshold = 0.2)
28+
#' principal_components(attitude, n = 3, sort = TRUE, threshold = 0.2)
2829
#'
29-
#' principal_components(attitude, n = 3, sort = TRUE, threshold = 0.2)
3030
#' \donttest{
31-
#' # Exploratory Factor Analysis (EFA) ---------
32-
#' efa <- psych::fa(attitude, nfactors = 3)
33-
#' model_parameters(efa, threshold = "max", sort = TRUE, labels = as.character(1:ncol(attitude)))
31+
#' # Exploratory Factor Analysis (EFA) ---------
32+
#' efa <- psych::fa(attitude, nfactors = 3)
33+
#' model_parameters(efa, threshold = "max", sort = TRUE, labels = as.character(1:ncol(attitude)))
3434
#' }
3535
#'
36-
#' # Omega ---------
37-
#' omega <- psych::omega(mtcars, nfactors = 3)
38-
#' params <- model_parameters(omega)
39-
#' params
40-
#' summary(params)
41-
#'
36+
#' # Omega ---------
37+
#' omega <- psych::omega(mtcars, nfactors = 3)
38+
#' params <- model_parameters(omega)
39+
#' params
40+
#' summary(params)
41+
#' }
4242
#'
4343
#' # FactoMineR ---------
4444
#' \dontrun{
45-
#' library(FactoMineR)
45+
#' if( require("FactoMineR")) {
46+
#' model <- FactoMineR::PCA(iris[, 1:4], ncp = 2)
47+
#' model_parameters(model)
48+
#' attributes(model_parameters(model))$scores
4649
#'
47-
#' model <- FactoMineR::PCA(iris[, 1:4], ncp = 2)
48-
#' model_parameters(model)
49-
#' attributes(model_parameters(model))$scores
50-
#'
51-
#' model <- FactoMineR::FAMD(iris, ncp = 2)
52-
#' model_parameters(model)
50+
#' model <- FactoMineR::FAMD(iris, ncp = 2)
51+
#' model_parameters(model)
52+
#' }
5353
#' }
5454
#' @return A data frame of loadings.
5555
#' @references \itemize{

R/model_parameters_mixed.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#' model <- lmer(mpg ~ wt + (1 | gear), data = mtcars)
2121
#' model_parameters(model)
2222
#' }
23-
#'
2423
#' \donttest{
2524
#' if (require("glmmTMB")) {
2625
#' data(Salamanders)

R/principal_components.R

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,24 @@
4949
#'
5050
#' @examples
5151
#' library(parameters)
52+
#' if (require("psych")) {
53+
#' principal_components(mtcars[, 1:7], n = "all", threshold = 0.2)
54+
#' principal_components(mtcars[, 1:7], n = 2, rotation = "oblimin",
55+
#' threshold = "max", sort = TRUE)
56+
#' principal_components(mtcars[, 1:7], n = 2, threshold = 2, sort = TRUE)
5257
#'
53-
#' principal_components(mtcars[, 1:7], n = "all", threshold = 0.2)
54-
#' principal_components(mtcars[, 1:7], n = 2, rotation = "oblimin", threshold = "max", sort = TRUE)
55-
#' principal_components(mtcars[, 1:7], n = 2, threshold = 2, sort = TRUE)
58+
#' pca <- principal_components(mtcars[, 1:5], n = 2, rotation = "varimax")
59+
#' summary(pca)
60+
#' predict(pca)
5661
#'
57-
#' pca <- principal_components(mtcars[, 1:5], n = 2, rotation = "varimax")
58-
#' summary(pca)
59-
#' predict(pca)
60-
#'
61-
#' # which variables from the original data belong to which extracted component?
62-
#' closest_component(pca)
62+
#' # which variables from the original data belong to which extracted component?
63+
#' closest_component(pca)
6364
#'
6465
#' \donttest{
65-
#' # Automated number of components
66-
#' principal_components(mtcars[, 1:4], n = "auto")
66+
#' # Automated number of components
67+
#' principal_components(mtcars[, 1:4], n = "auto")
68+
#' }
6769
#' }
68-
#'
6970
#' @return A data frame of loadings.
7071
#' @references \itemize{
7172
#' \item Kaiser, H.F. and Rice. J. (1974). Little jiffy, mark iv. Educational and Psychological Measurement, 34(1):111–117

man/model_parameters.gam.Rd

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

man/model_parameters.merMod.Rd

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/model_parameters.principal.Rd

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

man/principal_components.Rd

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

tests/testthat/test-model_parameters_std.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.runThisTest <- Sys.getenv("RunAllparametersTests") == "yes"
22

3-
if (.runThisTest || Sys.getenv("USER") == "travis") {
3+
if (.runThisTest) {
44

55
if (require("testthat") &&
66
require("parameters") &&

tests/testthat/test-model_parameters_std_mixed.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
.runThisTest <- Sys.getenv("RunAllparametersTests") == "yes"
22

3-
if (.runThisTest || Sys.getenv("USER") == "travis") {
3+
if (.runThisTest) {
44
if (require("testthat") &&
55
require("parameters") &&
6+
require("effectsize") &&
67
require("lme4")) {
78

89
data(iris)

0 commit comments

Comments
 (0)