diff --git a/.Rbuildignore b/.Rbuildignore index 95d493e..55d6b89 100755 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -16,3 +16,8 @@ cran-comments.md tests/* .travis.yml build.R +^likert\.Rproj$ +^\.github$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..14159b7 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,50 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd67eac --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.Rproj.user diff --git a/DESCRIPTION b/DESCRIPTION index b082e5d..67041cc 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: likert Type: Package Title: Analysis and Visualization Likert Items -Version: 2.0.0 +Version: 2.0.0.9000 Date: 2022-05-03 Authors@R: c( person("Jason", "Bryer", , "jason@bryer.org", role = c("aut", "cre"), @@ -9,7 +9,7 @@ Authors@R: c( person("Kim", "Speerschneider", , "kimkspeer@gmail.com", role = "ctb") ) Maintainer: Jason Bryer -URL: http://jason.bryer.org/likert, http://github.com/jbryer/likert +URL: https://jbryer.github.io/likert/, https://github.com/jbryer/likert BugReports: https://github.com/jbryer/likert/issues Description: An approach to analyzing Likert response items, with an emphasis on visualizations. The stacked bar plot is the preferred method for presenting Likert results. Tabular results @@ -20,7 +20,7 @@ License: GPL LazyLoad: yes VignetteBuilder: knitr Depends: - R (>= 3.0), ggplot2 (>= 2.2.0) + R (>= 3.0), ggplot2 (>= 3.4.0) Imports: psych, reshape2, @@ -31,11 +31,12 @@ Imports: colourpicker, shiny Suggests: - devtools, + remotes, knitr, rmarkdown, testthat (>= 3.0.0), vdiffr -RoxygenNote: 7.2.1 +RoxygenNote: 7.3.1 Encoding: UTF-8 +LazyData: true Config/testthat/edition: 3 diff --git a/NEWS b/NEWS.md old mode 100755 new mode 100644 similarity index 93% rename from NEWS rename to NEWS.md index dbb62eb..7f93f34 --- a/NEWS +++ b/NEWS.md @@ -1,5 +1,8 @@ -likert 2.0 -========= +# likert (development) + +* fixes for compatibility with ggplot2 (>= 3.4.0) + +# likert 2.0 * Many fixed to be compatible with the latest version of ggplot2. * Added digits parameter to plot for heatmaps. @@ -7,55 +10,54 @@ likert 2.0 * Print a warning if any variables are not factors. * New Shiny app that allows for interactively manipulate Likert options. -likert 1.3.6 -========= +# likert 1.3.6 + * Fixed a bug where the labels were placed on the wrong side. * Now require ggplot2 versions greater than 2.2.0. -likert 1.3.5 -========= +# likert 1.3.5 * Fixed a bug where stacked bars were in the wrong order in grouped plots. * Plotting options are now passed as a list. The likert.options returns the default set of plotting options. -likert 1.3.4 -========= +# likert 1.3.4 + * Fixed a bug where the neutral labels would be printed twice when there were an odd number of levels and plot.percents = TRUE. * Fixed a bug where the results for a grouped analysis with missing levels may not be correct in the print function. -likert 1.3.3 -========= +# likert 1.3.3 + * Update for ggplot2 version 2.0 -likert 1.3.2 -========= +# likert 1.3.2 + * Removed all use of the reshape package. * Fixes issue 40 where the histogram bars may not match the likert bars. -likert 1.3.1 -========= +# likert 1.3.1 + * Fix to work with the latest version of the xtable package. -likert 1.3.0 -========= +# likert 1.3.0 + * Added ability to group items by factor. * Converted all uses of reshape to reshape2. * Other fixes to pass R CMD CHECK. -likert 1.2.1 -========= +# likert 1.2.1 + * Added colors parameter to plot.likert.bar to define custom colors for levels. * Fixed bug where an unused factor level would not appear in the legend. -likert 1.2 -========= +# likert 1.2 + * Added initial support for conducting gap analysis. A demo, GapAnalysis has also been added. @@ -71,8 +73,8 @@ likert 1.2 * Fixed a bug where plot.likert(..., include.histogram=TRUE) would not work with a group and only one item (i.e. one column). * Updates for newer version of R and Roxygen. -likert 1.1 -========= +# likert 1.1 + Released September 25, 2013. diff --git a/R/likert-package.R b/R/likert-package.R index 825ee58..64c0324 100755 --- a/R/likert-package.R +++ b/R/likert-package.R @@ -1,10 +1,7 @@ -#' Likert Analysis and Visualization -#' -#' @name likert-package -#' @docType package -#' @title Likert Analysis and Visualization -#' @author \email{jason@@bryer.org} #' @keywords package institutional research likert +"_PACKAGE" + +## usethis namespace: start #' @import xtable #' @import ggplot2 #' @import gridExtra @@ -17,7 +14,9 @@ #' @importFrom stats cor cor.test density sd symnum #' @importFrom plyr llply #' @importFrom utils packageVersion -NA +## usethis namespace: end +NULL + #' Fictitious dataset with importance and satisfaction results across five different #' offices. @@ -25,11 +24,9 @@ NA #' This data set is used in the \code{GapAnalysis} demo and is used to demonstrate #' how the \code{likert} package handles a gap analysis. #' -#' @name gap -#' @docType data #' @format a data frame with 68 ovservations of 11 variables. #' @keywords datasets -NA +"gap" #' Results from the Survey of Academic Self-Regulation (SASR). #' @@ -37,28 +34,24 @@ NA #' self-regulation, intrinsic motivation, extrinsic motivation, self-efficacy, #' metacognition, and personal relevance and control. #' -#' @name sasr -#' @docType data #' @format a data frame with 860 ovservations of 63 variables. #' @keywords datasets #' @references Dugan, R., & Andrade, H. (2011). Exploring the construct validity #' of academic self-regulation using a new self-report questionnaire. The #' International Journal of Educational and Psychological Assessment, 7(1). -NA +"sasr" #' Programme of International Student Assessment #' #' North American (i.e. Canada, Mexico, and United States) results from the 2009 #' Programme of International Student Assessment (PISA) #' as provided by the Organization for Economic Co-operation and Development (OECD). -#' See \url{http://www.pisa.oecd.org/} for more information including the code book. +#' See \url{https://www.oecd.org/pisa/} for more information including the code book. #' -#' @name pisaitems -#' @docType data -#' @format a data frame 66,690 ovservations of 81 variables from North America. +#' @format a data frame 66,690 observations of 81 variables from North America. #' @source Organization for Economic Co-operation and Development #' @keywords datasets -NA +"pisaitems" #' Results from an administration of the Math Anxiety Scale Survey. #' @@ -66,28 +59,24 @@ NA #' to 20 students in a statistics course. This data frame contains the original #' data and can be used to verify the pre-summarized procedures. #' -#' @name mass -#' @docType data #' @format data frame with 14 rows and 6 columns. #' @references Bai, H., Wang, L., Pan, W., & Frey, M. (2009). Measuring mathematics #' anxiety: Psychometric analysis of a bidimensional affective scale. Journal of #' Instructional Psychology, 36 (3), 185- 193. #' @keywords datasets -NA +"mass" #' Pre-summarized results from an administration of the Math Anxiety Scale Survey. #' #' A data frame of presummarized results of the Math Anxiety Scale Survey administered #' to 20 students in a statistics course. #' -#' @name MathAnxiety -#' @docType data #' @format data frame with 14 rows and 6 columns. #' @references Bai, H., Wang, L., Pan, W., & Frey, M. (2009). Measuring mathematics #' anxiety: Psychometric analysis of a bidimensional affective scale. Journal of #' Instructional Psychology, 36 (3), 185- 193. #' @keywords datasets -NA +"MathAnxiety" #' Pre-summarized results from an administration of the Math Anxiety Scale Survey #' grouped by gender. @@ -95,14 +84,12 @@ NA #' A data frame of presummarized results of the Math Anxiety Scale Survey administered #' to 20 students in a statistics course grouped by gender. #' -#' @name MathAnxietyGender -#' @docType data #' @format data frame with 28 rows and 7 columns. #' @references Bai, H., Wang, L., Pan, W., & Frey, M. (2009). Measuring mathematics #' anxiety: Psychometric analysis of a bidimensional affective scale. Journal of #' Instructional Psychology, 36 (3), 185- 193. #' @keywords datasets -NA +"MathAnxietyGender" .onAttach <- function(libname, pkgname) { #pkgEnv = pos.to.env(match('package:likert', search())) @@ -114,11 +101,4 @@ that you detach this package as it causes conflicts with the reshape2 package. You can detach using the following R command: detach('package:reshape') ") } - - ggplot2.version <- as.integer(unlist(strsplit( - as.character(utils::packageVersion('ggplot2')), split='.', fixed=TRUE))) - if( (ggplot2.version[1] == 2 & ggplot2.version[2] < 2) | ggplot2.version[1] < 2) { - warning(paste0('Version ', ggplot2.version, ' of ggplot2 package detected. It is recommended ', - 'that use version 2.2.0 or newer.')) - } } diff --git a/R/plot.likert.bar.r b/R/plot.likert.bar.r index b9dbc3e..ed454ea 100755 --- a/R/plot.likert.bar.r +++ b/R/plot.likert.bar.r @@ -72,14 +72,14 @@ likert.bar.plot <- function(l, p <- NULL if(!is.null(l$grouping)) { ##### Grouping ################################## item_levels <- unique(l$results$Item) - item_levels <- likert:::label_wrap_mod(item_levels, width = wrap) - lsum$Item <- likert:::label_wrap_mod(lsum$Item, width = wrap) + item_levels <- label_wrap_mod(item_levels, width = wrap) + lsum$Item <- label_wrap_mod(lsum$Item, width = wrap) lsum$Item <- factor(lsum$Item, item_levels) levels(l$results$Item) <- levels(lsum$Item) #l$results$Item <- label_wrap_mod(l$results$Item, width=wrap) lsum$Item <- factor(lsum$Item,item_levels) #names(l$items) <- label_wrap_mod(names(l$items), width=wrap) - lsum$Group <- likert:::label_wrap_mod(lsum$Group, width=wrap.grouping) + lsum$Group <- label_wrap_mod(lsum$Group, width=wrap.grouping) results <- l$results results <- reshape2::melt(results, id=c('Group', 'Item')) results$variable <- factor(results$variable, ordered=TRUE) diff --git a/R/plot.likert.gap.R b/R/plot.likert.gap.R index b5a947b..2d5f6a8 100755 --- a/R/plot.likert.gap.R +++ b/R/plot.likert.gap.R @@ -36,7 +36,7 @@ plot.likert.gap <- function(x, type=c('bar','density'), panel.arrange='v', panel.strip.color='#F0F0F0', legend.position='bottom', - panel.background=element_rect(size=1, color='grey70', fill=NA), + panel.background=element_rect(linewidth=1, color='grey70', fill=NA), satisfaction.label='Satisfaction', importance.label='Importance', legend, diff --git a/R/plot.likert.matrix.r b/R/plot.likert.matrix.r index 741f3cd..c8a59c3 100755 --- a/R/plot.likert.matrix.r +++ b/R/plot.likert.matrix.r @@ -56,7 +56,7 @@ panel.hist <- function(x, ...) { rect(breaks[-nB], 0, breaks[-1], y, col="orange", ...) } - +#' @exportS3Method NULL pairs.ordered.categorical <- function(xx,...) { pairs(xx, diag.panel = panel.hist , diff --git a/R/plot.likert.r b/R/plot.likert.r index ad94d8c..c865b5b 100755 --- a/R/plot.likert.r +++ b/R/plot.likert.r @@ -36,7 +36,7 @@ plot.likert <- function(x, type=c('bar','heat','density'), panel.strip.color='#F0F0F0', legend.position='bottom', group.order, - panel.background=element_rect(size=1, color='grey70', fill=NA), + panel.background=element_rect(linewidth=1, color='grey70', fill=NA), ...) { if(missing(group.order) & !is.null(x$grouping) & include.histogram) { # Fixes this issue: https://github.com/jbryer/likert/issues/40 diff --git a/README.md b/README.md index dfc9b25..bcd2f4a 100755 --- a/README.md +++ b/README.md @@ -1,13 +1,19 @@ -### Analysis and Visualization of Likert Based Items +# Analysis and Visualization of Likert Based Items - + **Author: [Jason Bryer, Ph.D.](mailto:jason@bryer.org)** **Website: ** -[![Build Status](https://api.travis-ci.org/jbryer/likert.svg)](https://travis-ci.org/jbryer/likert?branch=master) -[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/likert)](http://cran.r-project.org/package=likert) + + +[![R-CMD-check](https://github.com/jbryer/likert/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jbryer/likert/actions/workflows/R-CMD-check.yaml) +[![Build Status](https://api.travis-ci.org/jbryer/likert.svg)](https://app.travis-ci.com/jbryer/likert?branch=master) +[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/likert)](https://cran.r-project.org/package=likert) ![Downloads](http://cranlogs.r-pkg.org/badges/likert) + + + `likert` is an R package designed to help analyzing and visualizing Likert type items. More information can be obtained at https://jbryer.github.io/likert. Also, the [included demo](https://github.com/jbryer/likert/blob/master/demo/likert.R) demonstrates many of the features. @@ -18,18 +24,18 @@ Download the 2013 useR! Conference [abstract](https://github.com/jbryer/likert/r The latest development version can be downloaded using the `devtools` package. -``` +```r remotes::install_github('jbryer/likert') ``` To get started take a look at the [likert demo](https://github.com/jbryer/likert/blob/master/demo/likert.R) or from within R: -``` +```r demo('likert', package='likert') ``` -Or run the [Shiny app](http://rstudio.com/shiny): +Or run the [Shiny app](https://shiny.posit.co/): -``` +```r shinyLikert() `` diff --git a/_pkgdown.yml b/_pkgdown.yml new file mode 100644 index 0000000..b7517c2 --- /dev/null +++ b/_pkgdown.yml @@ -0,0 +1,3 @@ +url: ~ +template: + bootstrap: 5 diff --git a/demo/00Index b/demo/00Index index 0d3f1dc..8164064 100755 --- a/demo/00Index +++ b/demo/00Index @@ -2,5 +2,5 @@ likert This demo creates likert plots for the PISA data. UnusedLevels This demo shows how to address the "All items (columns) must have the same number of levels" error that occurs when the items passed to likert do not have the same number of levels. RecodeFactors This demo shows how to recode likert items. This is useful if you wish to reverse the order from left-to-right how the likert responses are plotted or change the labels of responses (e.g. from numeric values to character values). PreSummarized This demo shows how to use the likert package with presummarized data. -GapAnalysis This demo shows how to perform a gap analysis where each item has two repsonses for satisfaction and importance. GroupedFactors This demo shows how to group by factors (i.e. group columns together). +mass Demo showing mass diff --git a/likert.Rproj b/likert.Rproj new file mode 100644 index 0000000..03e68f4 --- /dev/null +++ b/likert.Rproj @@ -0,0 +1,17 @@ +Version: 1.0 + +RestoreWorkspace: No +SaveWorkspace: No +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/man/MathAnxiety.Rd b/man/MathAnxiety.Rd index bc9637e..7ea86ba 100755 --- a/man/MathAnxiety.Rd +++ b/man/MathAnxiety.Rd @@ -7,6 +7,9 @@ \format{ data frame with 14 rows and 6 columns. } +\usage{ +MathAnxiety +} \description{ A data frame of presummarized results of the Math Anxiety Scale Survey administered to 20 students in a statistics course. diff --git a/man/MathAnxietyGender.Rd b/man/MathAnxietyGender.Rd index a6a5646..26976b1 100755 --- a/man/MathAnxietyGender.Rd +++ b/man/MathAnxietyGender.Rd @@ -8,6 +8,9 @@ grouped by gender.} \format{ data frame with 28 rows and 7 columns. } +\usage{ +MathAnxietyGender +} \description{ A data frame of presummarized results of the Math Anxiety Scale Survey administered to 20 students in a statistics course grouped by gender. diff --git a/man/figures/likert.png b/man/figures/logo.png old mode 100755 new mode 100644 similarity index 100% rename from man/figures/likert.png rename to man/figures/logo.png diff --git a/man/gap.Rd b/man/gap.Rd index e363ea0..18a0793 100755 --- a/man/gap.Rd +++ b/man/gap.Rd @@ -8,6 +8,9 @@ offices.} \format{ a data frame with 68 ovservations of 11 variables. } +\usage{ +gap +} \description{ This data set is used in the \code{GapAnalysis} demo and is used to demonstrate how the \code{likert} package handles a gap analysis. diff --git a/man/likert-package.Rd b/man/likert-package.Rd index ad20b64..db71bcd 100755 --- a/man/likert-package.Rd +++ b/man/likert-package.Rd @@ -3,12 +3,29 @@ \docType{package} \name{likert-package} \alias{likert-package} -\title{Likert Analysis and Visualization} +\title{likert: Analysis and Visualization Likert Items} \description{ -Likert Analysis and Visualization +\if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} + +An approach to analyzing Likert response items, with an emphasis on visualizations. The stacked bar plot is the preferred method for presenting Likert results. Tabular results are also implemented along with density plots to assist researchers in determining whether Likert responses can be used quantitatively instead of qualitatively. See the likert(), summary.likert(), and plot.likert() functions to get started. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://jbryer.github.io/likert/} + \item \url{https://github.com/jbryer/likert} + \item Report bugs at \url{https://github.com/jbryer/likert/issues} +} + } \author{ -\email{jason@bryer.org} +\strong{Maintainer}: Jason Bryer \email{jason@bryer.org} (\href{https://orcid.org/0000-0002-2454-0402}{ORCID}) + +Other contributors: +\itemize{ + \item Kim Speerschneider \email{kimkspeer@gmail.com} [contributor] +} + } \keyword{institutional} \keyword{likert} diff --git a/man/mass.Rd b/man/mass.Rd index 8cfb4dc..629331f 100755 --- a/man/mass.Rd +++ b/man/mass.Rd @@ -7,6 +7,9 @@ \format{ data frame with 14 rows and 6 columns. } +\usage{ +mass +} \description{ A data frame of results of the Math Anxiety Scale Survey administered to 20 students in a statistics course. This data frame contains the original diff --git a/man/pisaitems.Rd b/man/pisaitems.Rd index 1ea3f51..6b0006a 100755 --- a/man/pisaitems.Rd +++ b/man/pisaitems.Rd @@ -5,15 +5,18 @@ \alias{pisaitems} \title{Programme of International Student Assessment} \format{ -a data frame 66,690 ovservations of 81 variables from North America. +a data frame 66,690 observations of 81 variables from North America. } \source{ Organization for Economic Co-operation and Development } +\usage{ +pisaitems +} \description{ North American (i.e. Canada, Mexico, and United States) results from the 2009 Programme of International Student Assessment (PISA) as provided by the Organization for Economic Co-operation and Development (OECD). -See \url{http://www.pisa.oecd.org/} for more information including the code book. +See \url{https://www.oecd.org/pisa/} for more information including the code book. } \keyword{datasets} diff --git a/man/plot.likert.Rd b/man/plot.likert.Rd index 576deac..ee06154 100755 --- a/man/plot.likert.Rd +++ b/man/plot.likert.Rd @@ -13,7 +13,7 @@ panel.strip.color = "#F0F0F0", legend.position = "bottom", group.order, - panel.background = element_rect(size = 1, color = "grey70", fill = NA), + panel.background = element_rect(linewidth = 1, color = "grey70", fill = NA), ... ) } diff --git a/man/plot.likert.gap.Rd b/man/plot.likert.gap.Rd index b1fc033..ad7ee2b 100755 --- a/man/plot.likert.gap.Rd +++ b/man/plot.likert.gap.Rd @@ -12,7 +12,7 @@ panel.arrange = "v", panel.strip.color = "#F0F0F0", legend.position = "bottom", - panel.background = element_rect(size = 1, color = "grey70", fill = NA), + panel.background = element_rect(linewidth = 1, color = "grey70", fill = NA), satisfaction.label = "Satisfaction", importance.label = "Importance", legend, diff --git a/man/sasr.Rd b/man/sasr.Rd index b070e8d..bcf3971 100755 --- a/man/sasr.Rd +++ b/man/sasr.Rd @@ -7,6 +7,9 @@ \format{ a data frame with 860 ovservations of 63 variables. } +\usage{ +sasr +} \description{ The Survey of Academic Self-Regulation (SASR) is comprised of six factors: self-regulation, intrinsic motivation, extrinsic motivation, self-efficacy, diff --git a/slides/useR 2013/Slides/Slides.Rnw b/slides/useR 2013/Slides/Slides.Rnw index 07a32f0..058dd05 100755 --- a/slides/useR 2013/Slides/Slides.Rnw +++ b/slides/useR 2013/Slides/Slides.Rnw @@ -337,8 +337,8 @@ plot(l24g, type="density") \begin{itemize} \item release version 1.1 to CRAN (probably next week, currently available on GitHub) <>= -require(devtools) -install_github("likert","jbryer") +require(remotes) +install_github("jbryer/likert") @ \item \texttt{xtable} functions \item ability to analyze and visualize gap analysis (e.g. items with importance and satisfaction) diff --git a/vignettes/likert-xtable.Rnw b/vignettes/likert-xtable.Rnw index 7df2a0f..0f740c3 100755 --- a/vignettes/likert-xtable.Rnw +++ b/vignettes/likert-xtable.Rnw @@ -45,11 +45,11 @@ l24g <- likert(items24, grouping=pisaitems$CNT) \clearpage <>= -xtable(l24) +xtable::xtable(l24) @ <>= -xtable(l24g) +xtable::xtable(l24g) @ \end{landscape}