-
Notifications
You must be signed in to change notification settings - Fork 24
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
Bugs of frq related to sj-labelled character factors and tagged NA's, and minus select helpers #132
Comments
And another thing to see is in the |
Do you have a reproducible example? |
bump |
Actually, now I cannot imagine how I got to this issues. For the moment, I just quickly looked for an example for the first point:
xf <- factor(x, levels = c("Male", "Man" , "Lady", "Female"), labels = c("Male", "Male", "Female", "Female"))
xf
[1] Male Male Male Female Female
str(xf)
Factor w/ 2 levels "Male","Female": 1 1 1 2 2
library(sjlabelled)
attributes(set_labels(xf, labels = c("a", "b")))
$levels
[1] "Male" "Female"
$class
[1] "factor"
$labels
a b
"Female" "Male"
frq(set_labels(xf, labels = c("a", "b")))
x <categorical>
# total N=5 valid N=5 mean=1.40 sd=0.55
Value | Label | N | Raw % | Valid % | Cum. %
--------------------------------------------
1 | a | 3 | 60 | 60 | 60
2 | b | 2 | 40 | 40 | 100
<NA> | <NA> | 0 | 0 | <NA> | <NA> so for example value |
Now I can
library(haven)
x <- labelled(
as.integer(c(1:3, tagged_na("a", "c", "z"), 4:1)),
c("Agreement" = 1, "Disagreement" = 4, "First" = tagged_na("c"),
"Refused" = tagged_na("a"), "Not home" = tagged_na("z"))
)
frq(x)
Error in if (is.na(mydat$val[valid.vals]) & mydat$val[valid.vals + 1] == :
missing value where TRUE/FALSE needed |
I have now not much time to dive myself into the depths of
sjmisc::frq
again,so I write down here 2 issues I found lately and won't be able to solve soon.frq
applied to a character factor withsj
-labels does not print the labels in the correct order under generic conditions.frq
produces an error when applied to numeric data withsj
-labelledtagged_na
's.Thank you!
The text was updated successfully, but these errors were encountered: