Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for issue 16. Problem was related to using a numeric vector for g…

…roup.
  • Loading branch information...
commit 6ada695611ccf75a74832254f2d75f20014418a8 1 parent 613574f
@jbryer authored
Showing with 12 additions and 1 deletion.
  1. +2 −0  NEWS
  2. +5 −1 R/likert.R
  3. +5 −0 demo/UnusedLevels.R
View
2  NEWS
@@ -5,6 +5,8 @@ likert 1.2
* Can now create a likert object with a pre-summarized data frame.
* New Shiny app to demonstrate many of the features in the likert package. The
shinyLikert() function will start the app.
+* Fixed bug where text.color parameter was not being used.
+* Fixed bug 16.
likert 1.1
=========
View
6 R/likert.R
@@ -77,12 +77,16 @@ likert <- function(items, summary,
results <- data.frame()
if(!is.null(grouping)) {
+ if(is.numeric(gropuing)) {
+ grouping <- as.character(grouping)
+ }
results <- data.frame(
Group = rep(unique(grouping), each=nlevels),
Response = rep(1:nlevels, length(unique(grouping)))
)
for(i in 1:ncol(items)) {
- t <- as.data.frame(table(grouping, as.integer(items[,i])))
+ #t <- as.data.frame(table(grouping, as.integer(items[,i])))
+ t <- as.data.frame(table(grouping, items[,i]))
t <- cast(t, Var2 ~ grouping, value='Freq', add.missing=TRUE)
t <- apply(t, 2, FUN=function(x) { x / sum(x) * 100 } )
t <- melt(t)
View
5 demo/UnusedLevels.R
@@ -8,6 +8,7 @@ items <- data.frame('Item 1'=factor(sample(mylevels[1:4], 100, replace=TRUE)),
'Item 3'=factor(sample(mylevels[1:5], 100, replace=TRUE)),
check.names=FALSE)
str(items)
+groups <- sample(c('g1','g2'), 100, replace=TRUE)
tryCatch({
# This will throw an error because all the items must have the same number of levels.
@@ -28,3 +29,7 @@ lgood <- likert(items)
lgood
summary(lgood)
plot(lgood)
+
+lgr <- likert(items, grouping=groups)
+summary(lgr)
+plot(lgr)

2 comments on commit 6ada695

@andreaphsz

you have a typo on line 80 in R/likert.R:
if(is.numeric(gropuing)) should be if(is.numeric(grouping))

@jbryer
Owner

Thanks. Fixed.

Please sign in to comment.
Something went wrong with that request. Please try again.