Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demo(PreSummarized) not working #112

Open
franciscoss opened this issue Apr 22, 2020 · 1 comment
Open

demo(PreSummarized) not working #112

franciscoss opened this issue Apr 22, 2020 · 1 comment

Comments

@franciscoss
Copy link

Hi. I was trying to plot pre-summarized data, since I have survey weights that I'm taking into account with the survey package.

I couldn't get the likert function to work with my summarized data, so I tried with the included demo: demo(PreSummarized), but it gave me the following error:

Error in as.data.frame(items) : 
  argument "items" is missing, with no default

Do you know what the problem is, or how can I make it work with pre-summarized data?

Thanks,

@franciscoss franciscoss changed the title demo(PreSummarized) not workin. demo(PreSummarized) not working Apr 22, 2020
@gkalvelage
Copy link
Contributor

I ran into the same issue and found a workaround. I'm not sure, why the "items" argument is needed, since the pre-summarized data frame should include a factor with the items as levels. For me, it worked inserting just any string (see below).

If you do so, you'll run into a different error, which arises from a change in 87c5500, if I'm correct:

names(summary)[1] <- 'Items'

I had to change the column's name to make it work with the plotting function.

Hope that helps.

# devtools::install_github("jbryer/likert")
library("likert")
#> Loading required package: ggplot2
#> Loading required package: xtable

## Using pre-summarized data and no groups from demo(PreSummarized)
data(MathAnxiety)

# does not work
lmass <- likert(summary=MathAnxiety)
#> Error in as.data.frame(items): argument "items" is missing, with no default

# does work: insert any character (which throws a warning only)
lmass <- likert(items = "blank", summary=MathAnxiety)
#> Warning in likert(items = "blank", summary = MathAnxiety): Variable items is not
#> a factor.

## different issue: wrong name of "Items" column in likert.R
names(lmass[["results"]])[1]
#> [1] "Items"

# correct column name to "Item"
names(lmass[["results"]])[1] <- "Item"

# plotting
plot(lmass)

Created on 2020-05-17 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.0 (2020-04-24)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language en                          
#>  collate  German_Germany.1252         
#>  ctype    German_Germany.1252         
#>  tz       Europe/Berlin               
#>  date     2020-05-17                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version   date       lib source                        
#>  assertthat    0.2.1     2019-03-21 [1] CRAN (R 4.0.0)                
#>  backports     1.1.6     2020-04-05 [1] CRAN (R 4.0.0)                
#>  callr         3.4.3     2020-03-28 [1] CRAN (R 4.0.0)                
#>  cli           2.0.2     2020-02-28 [1] CRAN (R 4.0.0)                
#>  colorspace    1.4-1     2019-03-18 [1] CRAN (R 4.0.0)                
#>  crayon        1.3.4     2017-09-16 [1] CRAN (R 4.0.0)                
#>  curl          4.3       2019-12-02 [1] CRAN (R 4.0.0)                
#>  desc          1.2.0     2018-05-01 [1] CRAN (R 4.0.0)                
#>  devtools      2.3.0     2020-04-10 [1] CRAN (R 4.0.0)                
#>  digest        0.6.25    2020-02-23 [1] CRAN (R 4.0.0)                
#>  dplyr         0.8.5     2020-03-07 [1] CRAN (R 4.0.0)                
#>  ellipsis      0.3.0     2019-09-20 [1] CRAN (R 4.0.0)                
#>  evaluate      0.14      2019-05-28 [1] CRAN (R 4.0.0)                
#>  fansi         0.4.1     2020-01-08 [1] CRAN (R 4.0.0)                
#>  farver        2.0.3     2020-01-16 [1] CRAN (R 4.0.0)                
#>  fs            1.4.1     2020-04-04 [1] CRAN (R 4.0.0)                
#>  ggplot2     * 3.3.0     2020-03-05 [1] CRAN (R 4.0.0)                
#>  glue          1.4.0     2020-04-03 [1] CRAN (R 4.0.0)                
#>  gridExtra     2.3       2017-09-09 [1] CRAN (R 4.0.0)                
#>  gtable        0.3.0     2019-03-25 [1] CRAN (R 4.0.0)                
#>  highr         0.8       2019-03-20 [1] CRAN (R 4.0.0)                
#>  htmltools     0.4.0     2019-10-04 [1] CRAN (R 4.0.0)                
#>  httr          1.4.1     2019-08-05 [1] CRAN (R 4.0.0)                
#>  knitr         1.28      2020-02-06 [1] CRAN (R 4.0.0)                
#>  labeling      0.3       2014-08-23 [1] CRAN (R 4.0.0)                
#>  lattice       0.20-41   2020-04-02 [1] CRAN (R 4.0.0)                
#>  lifecycle     0.2.0     2020-03-06 [1] CRAN (R 4.0.0)                
#>  likert      * 1.3.6     2020-05-17 [1] Github (jbryer/likert@a7cb925)
#>  magrittr      1.5       2014-11-22 [1] CRAN (R 4.0.0)                
#>  memoise       1.1.0     2017-04-21 [1] CRAN (R 4.0.0)                
#>  mime          0.9       2020-02-04 [1] CRAN (R 4.0.0)                
#>  mnormt        1.5-7     2020-04-30 [1] CRAN (R 4.0.0)                
#>  munsell       0.5.0     2018-06-12 [1] CRAN (R 4.0.0)                
#>  nlme          3.1-147   2020-04-13 [1] CRAN (R 4.0.0)                
#>  pillar        1.4.4     2020-05-05 [1] CRAN (R 4.0.0)                
#>  pkgbuild      1.0.8     2020-05-07 [1] CRAN (R 4.0.0)                
#>  pkgconfig     2.0.3     2019-09-22 [1] CRAN (R 4.0.0)                
#>  pkgload       1.0.2     2018-10-29 [1] CRAN (R 4.0.0)                
#>  plyr          1.8.6     2020-03-03 [1] CRAN (R 4.0.0)                
#>  prettyunits   1.1.1     2020-01-24 [1] CRAN (R 4.0.0)                
#>  processx      3.4.2     2020-02-09 [1] CRAN (R 4.0.0)                
#>  ps            1.3.3     2020-05-08 [1] CRAN (R 4.0.0)                
#>  psych         1.9.12.31 2020-01-08 [1] CRAN (R 4.0.0)                
#>  purrr         0.3.4     2020-04-17 [1] CRAN (R 4.0.0)                
#>  R6            2.4.1     2019-11-12 [1] CRAN (R 4.0.0)                
#>  Rcpp          1.0.4.6   2020-04-09 [1] CRAN (R 4.0.0)                
#>  remotes       2.1.1     2020-02-15 [1] CRAN (R 4.0.0)                
#>  reshape2      1.4.4     2020-04-09 [1] CRAN (R 4.0.0)                
#>  rlang         0.4.5     2020-03-01 [1] CRAN (R 4.0.0)                
#>  rmarkdown     2.1       2020-01-20 [1] CRAN (R 4.0.0)                
#>  rprojroot     1.3-2     2018-01-03 [1] CRAN (R 4.0.0)                
#>  scales        1.1.0     2019-11-18 [1] CRAN (R 4.0.0)                
#>  sessioninfo   1.1.1     2018-11-05 [1] CRAN (R 4.0.0)                
#>  stringi       1.4.6     2020-02-17 [1] CRAN (R 4.0.0)                
#>  stringr       1.4.0     2019-02-10 [1] CRAN (R 4.0.0)                
#>  testthat      2.3.2     2020-03-02 [1] CRAN (R 4.0.0)                
#>  tibble        3.0.1     2020-04-20 [1] CRAN (R 4.0.0)                
#>  tidyselect    1.0.0     2020-01-27 [1] CRAN (R 4.0.0)                
#>  usethis       1.6.1     2020-04-29 [1] CRAN (R 4.0.0)                
#>  vctrs         0.2.4     2020-03-10 [1] CRAN (R 4.0.0)                
#>  withr         2.2.0     2020-04-20 [1] CRAN (R 4.0.0)                
#>  xfun          0.13      2020-04-13 [1] CRAN (R 4.0.0)                
#>  xml2          1.3.2     2020-04-23 [1] CRAN (R 4.0.0)                
#>  xtable      * 1.8-4     2019-04-21 [1] CRAN (R 4.0.0)                
#>  yaml          2.2.1     2020-02-01 [1] CRAN (R 4.0.0)                
#> 
#> [1] C:/Users/gkalvelage/R/R-4.0.0/library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants