Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: parameters
Title: Processing of Model Parameters
Version: 0.26.0.10
Version: 0.26.0.11
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
3 changes: 2 additions & 1 deletion R/utils_pca_efa.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#' indicating their column positions in `x` that should be reversed before
#' computing sum scores. This is useful when the items are not coded in the same
#' direction. If `NULL` (default), no items are reversed.
#' @param verbose Logical, whether to print messages about reversing items.
#'
#' @details
#' `get_scores()` takes the results from [`principal_components()`] or
Expand Down Expand Up @@ -51,7 +52,7 @@
#' (mtcars$hp + mtcars$qsec) / 2
#'
#' @export
get_scores <- function(x, n_items = NULL, reverse_items = NULL) {
get_scores <- function(x, n_items = NULL, reverse_items = NULL, verbose = TRUE) {
subscales <- closest_component(x)
dataset <- attributes(x)$dataset

Expand Down Expand Up @@ -334,7 +335,7 @@
# extract model
model <- attributes(x)$model
if (!is.null(model)) {
stats <- data.frame(

Check warning on line 338 in R/utils_pca_efa.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/utils_pca_efa.R,line=338,col=14,[strings_as_factors_linter] Supply an explicit value for stringsAsFactors for this code to work before and after R version 4.0.
Statistic = c("Alpha", "G.6", "Omega (hierarchical)", "Omega (asymptotic H)", "Omega (total)"),
Coefficient = c(model$alpha, model$G6, model$omega_h, model$omega.lim, model$omega.tot)
)
Expand Down
4 changes: 3 additions & 1 deletion man/get_scores.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/testthat/test-get_scores.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@ test_that("get_scores", {
scores <- get_scores(pca)
expect_equal(head(scores$Component_1), c(38.704, 38.755, 28.194, 58.339, 78.658, 51.064), tolerance = 1e-2)
expect_equal(head(scores$Component_2), c(63.23, 63.51, 55.805, 64.72, 96.01, 62.61), tolerance = 1e-2)

scores2 <- get_scores(pca, reverse_items = c("cyl", "drat"))
expect_equal(head(scores2$Component_1), c(38.682, 38.733, 28.992, 58.645, 78.136, 51.498), tolerance = 1e-2)

expect_warning(
get_scores(pca, reverse_items = c("cyl", "abc")),
regex = "Following variable(s)",
fixed = TRUE
)
})
Loading