You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If data is of class tbl_df (or inherits from it), likert::likert() should be able to handle it without issue.
Actual Behavior
Handing in data inheriting from class tbl_df produces an error:
Error in likert(test_data) :
The items parameter must be a data frame. If trying to subset a data frame to analyze only one column, try: items=mydf[,1, drop=FALSE].
In addition: Warning message:
In if (class(items) != "data.frame") { :
the condition has length > 1 and only the first element will be used
Steps to Reproduce
# Checkpoint for reproducibility
require(checkpoint)
checkpoint("2016-03-30", R.version="3.2.4")
require(dplyr)
require(likert)
data("pisaitems")
test_data<-pisaitems %>%
select(one_of("ST24Q02", "ST24Q01")) %>%
tbl_df()
# If `test_data` is a `tbl_df`, this call will fail because likert() claims the# `items` parameter is not a data frame
likert(test_data)
# Calling `class()` on `test_data` shows it inherits from multiple classes,# including `data.frame`. So, I'm not sure what's happening exactly,# but I suspect it's related to this source code block: https://github.com/jbryer/likert/blob/4ff9837ffa17085219c5b23f5e8319b0405e2893/R/likert.R#L71-L74
class(test_data)
# Coercing `test_data` back to a data frame fixes the issue,# but is there any reason `tbl_df` data should be failing?
as.data.frame(test_data) %>% likert()
Where I suspect the error might be originating
Based on my inspection, the only part of the likert package source code that could produce this error is here:
Expected Behavior
If data is of class
tbl_df
(or inherits from it),likert::likert()
should be able to handle it without issue.Actual Behavior
Handing in data inheriting from class
tbl_df
produces an error:Steps to Reproduce
Where I suspect the error might be originating
Based on my inspection, the only part of the likert package source code that could produce this error is here:
likert/R/likert.R
Lines 71 to 74 in 4ff9837
Which in turn means this conditional check is returning
TRUE
:Session Info
The text was updated successfully, but these errors were encountered: