Skip to content
Prev 387408 / 398502 Next

[External] Re: [External] Re: Help please

The likert() function in library(likert) is not the same as
the likert() function in library(HH).

The likert function in the likert package creates an object that needs to be plotted.
For the likert package you left out the line
        plot(likert::likert(scrounging))
This plot is not consistent with what your initial email said it was looking for.


Both Jim Lemon and I gave you plots that are consistent with your description.
You could probably get a similar plot from likert::likert(), but not by the lines you are using.
The likert::likert() function does not work with the table that HH::likert() and barplot() are using.
look at str(l29) to see what it needs

The likert package and the HH package cannot be loaded simultaneously.
Their use the same function names in incompatible ways.

How to get the ?likert::likert plot using HH:

HH::likert(t(sapply(items29, table)), as.percent=TRUE, positive.order=TRUE)

Here is a complete example using Jim Lemon's data.



## NO library() statements!
## The likert and HH packages have incompatible usage
## of the same function names.

## this is the example from ?likert::likert
data(pisaitems, package="likert")
items29 <- pisaitems[,substr(names(pisaitems), 1,5) == 'ST25Q']
names(items29) <- c("Magazines", "Comic books", "Fiction",
                    "Non-fiction books", "Newspapers")
## plot using likert package
l29 <- likert::likert(items29)
likert:::plot.likert(l29)


## plot using HH package
HH::likert(t(sapply(items29, table)), as.percent=TRUE,
           positive.order=TRUE, main="HH::likert")

HH::likert(t(sapply(items29, table)), as.percent=TRUE,
           positive.order=TRUE, main="HH::likert",
           auto.key=list(columns=2),
           scales=list(y=list(tck=c(0,2)))) ## prettier



## Jim Lemon's example
scrounging <- data.frame(
  behav=sample(c("inactive","active","foraging","snoozing"),50,TRUE),
  substr=sample(c("tree","ground","vine","air"),50,TRUE))

scroungeTable <- t(table(scrounging))
scroungeTable
HH::likert(scroungeTable)

## I don't think Jim Lemon's example can be used directly in the likert package.
## look at
str(l29)
## and notice that it must include both raw data and the table
l29$results
head(l29$items)


## For any further discussion on this list please include the output from
dput(head(yourRealData))
## in the body of the email.

## Jim's example is based on base graphics barplot
## The HH likert() function is based on lattice barchart.
## the likert package's likert:::plot.likert() function is based on ggplot.