diff --git a/DESCRIPTION b/DESCRIPTION index 6a535a2ed159df5c660a02d46eebfce3003d1dc0..896a2ae5135dff346d8a2595720035cd7f516310 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ufs Type: Package Title: A Collection of Utilities -Version: 0.5.4 +Version: 0.5.5 Authors@R: c( person(given = "Gjalt-Jorn", @@ -33,7 +33,7 @@ URL: https://r-packages.gitlab.io/ufs BugReports: https://gitlab.com/r-packages/ufs/-/issues Encoding: UTF-8 LazyData: true -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.3 Depends: R (>= 3.0.0) Suggests: bootES (>= 1.2), diff --git a/R/ggSave.R b/R/ggSave.R index f8cad0d3c11e770f88a92192418b68974b09162f..a994d022de557e516b284fa274330438eb11f981 100644 --- a/R/ggSave.R +++ b/R/ggSave.R @@ -13,6 +13,11 @@ #' @param type An additional arguments for the graphic device. #' @param device The graphic device; is inferred from the file if not specified. #' @param bg The background (e.g. 'white'). +#' @param preventType Whether to prevent passing a value for the `type` argument +#' to [ggplot2::ggsave()]. This is prevented by default since {gglot} switched +#' to using the ragg device by default, resulting in throwing a warning +#' ("Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments") +#' if something if passed for 'type'. #' @param ... Any additional arguments are passed on to [ggplot2::ggsave()]. #' #' @return The plot, invisibly. @@ -25,7 +30,9 @@ ggSave <- function(file=NULL, plot = ggplot2::last_plot(), height=ufs::opts$get("ggSaveFigHeight"), units=ufs::opts$get("ggSaveUnits"), dpi=ufs::opts$get("ggSaveDPI"), - device=NULL, type=NULL, bg="transparent", ...) { + device=NULL, type=NULL, bg="transparent", + preventType = ufs::opts$get("ggSavePreventType"), + ...) { extension <- gsub("^.*\\.(.+)$", "\\1", file); @@ -91,9 +98,18 @@ ggSave <- function(file=NULL, plot = ggplot2::last_plot(), } if (device[i]=="png") { - ggplot2::ggsave(file=file[i], plot=plot, device=device[i], - height=height[i], width=width[i], units=units[i], - dpi=dpi[i], type=type[i], bg = bg[i], ...); + if (preventType) { + ### Preventing type by default since gglot uses the ragg device, + ### otherwise it throws + ### "Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments" + ggplot2::ggsave(file=file[i], plot=plot, device=device[i], + height=height[i], width=width[i], units=units[i], + dpi=dpi[i], bg = bg[i], ...); + } else{ + ggplot2::ggsave(file=file[i], plot=plot, device=device[i], + height=height[i], width=width[i], units=units[i], + dpi=dpi[i], type=type[i], bg = bg[i], ...); + } } else if (device[i]=="svg") { ### The 'svg' device doesn't have a 'type' argument ggplot2::ggsave(file=file[i], plot=plot, device=device[i], @@ -105,9 +121,18 @@ ggSave <- function(file=NULL, plot = ggplot2::last_plot(), height=height[i], width=width[i], units=units[i], dpi=dpi[i], bg = bg[i], ...); } else { - ggplot2::ggsave(file=file[i], plot=plot, device=device[i], - height=height[i], width=width[i], units=units[i], - dpi=dpi[i], type=type[i], bg = bg[i], ...); + if (preventType) { + ### Preventing type by default since gglot uses the ragg device, + ### otherwise it throws + ### "Warning: Using ragg device as default. Ignoring `type` and `antialias` arguments" + ggplot2::ggsave(file=file[i], plot=plot, device=device[i], + height=height[i], width=width[i], units=units[i], + dpi=dpi[i], bg = bg[i], ...); + } else { + ggplot2::ggsave(file=file[i], plot=plot, device=device[i], + height=height[i], width=width[i], units=units[i], + dpi=dpi[i], type=type[i], bg = bg[i], ...); + } } } diff --git a/R/opts.R b/R/opts.R index f8f70a61ff1400d52b09ed55f27509475faf02ec..5f9b85aa361a26aad75ec6e85d36eb509f5d1722 100644 --- a/R/opts.R +++ b/R/opts.R @@ -240,6 +240,8 @@ opts$defaults <- knitAndSave.catPlot = FALSE, knitFig.catPlot = FALSE, + ggSavePreventType = TRUE, + ### Careless options carelessDict = list(c("_chr", ""), c("irv", "IRV "), diff --git a/R/parallelSubscales.R b/R/parallelSubscales.R index 4cf0a66cb8ef9e2ba8fa8d678b78855770fe20b5..7a0523ea2d5c4dc5c585c445b5cea66cd71c172d 100644 --- a/R/parallelSubscales.R +++ b/R/parallelSubscales.R @@ -10,7 +10,6 @@ #' and when printed shows the descriptives; or, for the print function, `x`, #' invisibly. #' -#' @examples #' @rdname parallelSubscales #' @export parallelSubscales <- function(dat, convertToNumeric = TRUE) { diff --git a/R/scaleStructure.R b/R/scaleStructure.R index b32dbfa5c3ea5af9104512c21baa6757e13ea5c8..88bee2eb1f39d7207bc7589810ded97ec5d47080 100644 --- a/R/scaleStructure.R +++ b/R/scaleStructure.R @@ -152,12 +152,15 @@ #' #' ### Use all items (don't order confidence intervals to save time #' ### during automated testing of the example) -#' scaleStructure(dat=exampleData, ci=FALSE); +#' ufs::scaleStructure(dat=exampleData, ci=FALSE); #' #' ### Use a selection of three variables (without confidence #' ### intervals to save time -#' scaleStructure(dat=exampleData, items=c('t0_item2', 't0_item3', 't0_item4'), -#' ci=FALSE); +#' ufs::scaleStructure( +#' dat=exampleData, +#' items=c('t0_item2', 't0_item3', 't0_item4'), +#' ci=FALSE +#' ); #' #' ### Make the items resemble an ordered categorical (ordinal) scale #' ordinalExampleData <- data.frame(apply(exampleData, 2, cut, @@ -165,7 +168,7 @@ #' labels=as.character(1:5))); #' #' ### Now we also get estimates assuming the ordinal measurement level -#' scaleStructure(ordinalExampleData, ci=FALSE); +#' ufs::scaleStructure(ordinalExampleData, ci=FALSE); #' } #' #' @@ -294,29 +297,50 @@ scaleStructure <- scaleReliability <- function (data=NULL, items = 'all', digits res$output$coefficientH <- 1 / (1 + res$intermediate$minorDenom); ### GLB - suppressWarnings(res$intermediate$glb <- - psych::glb(res$input$dat)); - res$output$glb <- res$intermediate$glb$glb.max; - res$output$dat$glb <- res$intermediate$glb$glb.max; + tryCatch( + suppressWarnings(res$intermediate$glb <- + psych::glb(res$input$dat)), + error = function(e) { + warning("\n\nWhen calling `psych::glb`, it threw an ", + "error, specifically:\n\n", e, + "\nThis prevents me from providing an ", + "estimate for the Greatest Lower Bound (GLB). I am setting ", + "it to NA."); + } + ) + if (is.null(res$intermediate$glb)) { + res$intermediate$glb <- list(glb.max = NA); + res$output$glb <- NA; + res$output$dat$glb <- NA; + } else { + res$output$glb <- res$intermediate$glb$glb.max; + res$output$dat$glb <- res$intermediate$glb$glb.max; + } ### Omega if (requireNamespace("psych", quietly = TRUE)) { - invisible( - utils::capture.output( - suppressMessages( - suppressWarnings( - res$intermediate$omega.psych <- - psych::omega(res$input$dat, - nfactors = omega.psych_nfactors, - flip = omega.psych_flip, - plot = FALSE) + if (requireNamespace("GPArotation", quietly = TRUE)) { + invisible( + utils::capture.output( + suppressMessages( + suppressWarnings( + res$intermediate$omega.psych <- + psych::omega(res$input$dat, + nfactors = omega.psych_nfactors, + flip = omega.psych_flip, + plot = FALSE) + ) ) ) - ) - ); - res$output$omega.psych <- res$intermediate$omega.psych$omega.tot; - res$output$dat$omega.psych.tot <- res$output$omega.psych; - res$output$dat$omega.psych.h <- res$intermediate$omega.psych$omega_h; + ); + res$output$omega.psych <- res$intermediate$omega.psych$omega.tot; + res$output$dat$omega.psych.tot <- res$output$omega.psych; + res$output$dat$omega.psych.h <- res$intermediate$omega.psych$omega_h; + } else { + stop("\n\nIf you want to compute omega, you need the {psych} package, ", + "which in turn needs the {GPArotation} package. You can ", + "install it with:\n\ninstall.packages('GPArotation');\n\n"); + } } if (requireNamespace("MBESS", quietly = TRUE)) { res$intermediate$omega <- diff --git a/man/aipedjmv.Rd b/man/aipedjmv.Rd index 0a908e264f5c46dd4a3e24ab78420535b1aa787e..360a575f5bd9815c72876a4314da6595b50d0eb4 100644 --- a/man/aipedjmv.Rd +++ b/man/aipedjmv.Rd @@ -1,10 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/aipedjmv.h.R +\docType{data} \name{aipedjmv} \alias{aipedjmv} \title{Sample size for accuracy: d} +\format{ +An object of class \code{NULL} of length 0. +} \usage{ -aipedjmv(d = 0.5, w = 0.1, conf.level = 95) +aipedjmv } \arguments{ \item{d}{.} @@ -23,3 +27,4 @@ A results object containing: \description{ Sample size for accuracy: d } +\keyword{datasets} diff --git a/man/aiperjmv.Rd b/man/aiperjmv.Rd index 35782af038e8bfaf9963bcbf3f1b22a33a7ca021..b4912e48a85cb4c77aeb0947fab3962680286084 100644 --- a/man/aiperjmv.Rd +++ b/man/aiperjmv.Rd @@ -1,10 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/aiperjmv.h.R +\docType{data} \name{aiperjmv} \alias{aiperjmv} \title{Sample size for accuracy: r} +\format{ +An object of class \code{NULL} of length 0. +} \usage{ -aiperjmv(r = 0.3, w = 0.1, conf.level = 95) +aiperjmv } \arguments{ \item{r}{.} @@ -23,3 +27,4 @@ A results object containing: \description{ Sample size for accuracy: r } +\keyword{datasets} diff --git a/man/confintdjmv.Rd b/man/confintdjmv.Rd index b0b46a532fbd43b2ee2a5f5992d16ad11fc8b550..2b8d7703a84ae7111f68769628ae58359fb364b7 100644 --- a/man/confintdjmv.Rd +++ b/man/confintdjmv.Rd @@ -1,10 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/confintdjmv.h.R +\docType{data} \name{confintdjmv} \alias{confintdjmv} \title{Effect Size Confidence Interval: Cohens's d} +\format{ +An object of class \code{NULL} of length 0. +} \usage{ -confintdjmv(d = 0.5, n = 128, conf.level = 95) +confintdjmv } \arguments{ \item{d}{.} @@ -23,3 +27,4 @@ A results object containing: \description{ Effect Size Confidence Interval: Cohens's d } +\keyword{datasets} diff --git a/man/confintrjmv.Rd b/man/confintrjmv.Rd index c3003c54417395cda1a76e892f75d76c4a5fb9d8..6423060609ab39815e5fa758dc45ef2cff422b60 100644 --- a/man/confintrjmv.Rd +++ b/man/confintrjmv.Rd @@ -1,10 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/confintrjmv.h.R +\docType{data} \name{confintrjmv} \alias{confintrjmv} \title{Effect Size Confidence Interval: Pearson's r} +\format{ +An object of class \code{NULL} of length 0. +} \usage{ -confintrjmv(r = 0.3, N = 400, conf.level = 95) +confintrjmv } \arguments{ \item{r}{.} @@ -23,3 +27,4 @@ A results object containing: \description{ Effect Size Confidence Interval: Pearson's r } +\keyword{datasets} diff --git a/man/descriptives.Rd b/man/descriptives.Rd index 80ab2e608262af8f949dfe8103e080e8ccaed304..09055323d1f758169507d7b05aa495ac4f364b5f 100644 --- a/man/descriptives.Rd +++ b/man/descriptives.Rd @@ -14,8 +14,7 @@ descr( x, digits = 4, errorOnFactor = FALSE, - include = c("central tendency", "spread", "range", "distribution shape", - "sample size"), + include = c("central tendency", "spread", "range", "distribution shape", "sample size"), maxModes = 1, t = FALSE, conf.level = 0.95, @@ -26,8 +25,7 @@ descr( x, digits = 4, errorOnFactor = FALSE, - include = c("central tendency", "spread", "range", "distribution shape", - "sample size"), + include = c("central tendency", "spread", "range", "distribution shape", "sample size"), maxModes = 1, t = FALSE, conf.level = 0.95, diff --git a/man/ggSave.Rd b/man/ggSave.Rd index 8c3baadfc504f094cf48e78bbbebf081b0cf2803..b90939b196a0b242a8e59f8c77e30e38c143bd04 100644 --- a/man/ggSave.Rd +++ b/man/ggSave.Rd @@ -14,6 +14,7 @@ ggSave( device = NULL, type = NULL, bg = "transparent", + preventType = ufs::opts$get("ggSavePreventType"), ... ) } @@ -34,6 +35,12 @@ ggSave( \item{bg}{The background (e.g. 'white').} +\item{preventType}{Whether to prevent passing a value for the \code{type} argument +to \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}}. This is prevented by default since {gglot} switched +to using the ragg device by default, resulting in throwing a warning +("Warning: Using ragg device as default. Ignoring \code{type} and \code{antialias} arguments") +if something if passed for 'type'.} + \item{...}{Any additional arguments are passed on to \code{\link[ggplot2:ggsave]{ggplot2::ggsave()}}.} } \value{ diff --git a/man/meansDiamondPlotjmv.Rd b/man/meansDiamondPlotjmv.Rd index a794313fbee10301bd56039e556bbd6e97b6fbc7..a8523ce9c27a392e8986a395e3427d6abc9c165f 100644 --- a/man/meansDiamondPlotjmv.Rd +++ b/man/meansDiamondPlotjmv.Rd @@ -1,10 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/meansdiamondplotjmv.h.R +\docType{data} \name{meansDiamondPlotjmv} \alias{meansDiamondPlotjmv} \title{Diamond plot: means} +\format{ +An object of class \code{NULL} of length 0. +} \usage{ -meansDiamondPlotjmv(data, items, conf.level = 95, showData = TRUE) +meansDiamondPlotjmv } \arguments{ \item{data}{.} @@ -25,3 +29,4 @@ A results object containing: \description{ Diamond plot: means } +\keyword{datasets} diff --git a/man/multiResponsejmv.Rd b/man/multiResponsejmv.Rd index 7a003245c3a1a0c02d6360cf682f35b0eccb3c71..f2bb75ea01275c485ea9739a9ea1449772577675 100644 --- a/man/multiResponsejmv.Rd +++ b/man/multiResponsejmv.Rd @@ -1,10 +1,14 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/multiresponsejmv.h.R +\docType{data} \name{multiResponsejmv} \alias{multiResponsejmv} \title{Multi Response} +\format{ +An object of class \code{NULL} of length 0. +} \usage{ -multiResponsejmv(data, items, endorsedOption = 1) +multiResponsejmv } \arguments{ \item{data}{.} @@ -28,3 +32,4 @@ Tables can be converted to data frames with \code{asDF} or \code{\link{as.data.f \description{ Multi Response } +\keyword{datasets} diff --git a/man/scaleStructure.Rd b/man/scaleStructure.Rd index db78339ad453979950108fc8055861508949a435..82e293c97b3c8ec30b441ed77c6560cee38bcb30 100644 --- a/man/scaleStructure.Rd +++ b/man/scaleStructure.Rd @@ -174,12 +174,15 @@ exampleData <- testRetestSimData[2:6]; ### Use all items (don't order confidence intervals to save time ### during automated testing of the example) -scaleStructure(dat=exampleData, ci=FALSE); +ufs::scaleStructure(dat=exampleData, ci=FALSE); ### Use a selection of three variables (without confidence ### intervals to save time -scaleStructure(dat=exampleData, items=c('t0_item2', 't0_item3', 't0_item4'), - ci=FALSE); +ufs::scaleStructure( + dat=exampleData, + items=c('t0_item2', 't0_item3', 't0_item4'), + ci=FALSE +); ### Make the items resemble an ordered categorical (ordinal) scale ordinalExampleData <- data.frame(apply(exampleData, 2, cut, @@ -187,7 +190,7 @@ ordinalExampleData <- data.frame(apply(exampleData, 2, cut, labels=as.character(1:5))); ### Now we also get estimates assuming the ordinal measurement level -scaleStructure(ordinalExampleData, ci=FALSE); +ufs::scaleStructure(ordinalExampleData, ci=FALSE); } diff --git a/man/testRetestReliability.Rd b/man/testRetestReliability.Rd index 9391dbeee1d8976a02b7c3f6867800325d30ee9d..23435ea16e9df9fc08b711b422c7330b91f6e9b3 100644 --- a/man/testRetestReliability.Rd +++ b/man/testRetestReliability.Rd @@ -52,6 +52,10 @@ order of the items at each measurement moment is the same.} vectors in the dataframes to numeric.} \item{digits}{Number of digits to show when printing the output} + +\item{x}{The object to print} + +\item{...}{Passed on to the print function} } \value{ An object with the input and several output variables. Most notably: