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
Undesired behaviour with cro_cases function when value labels are defined #3
Comments
Hi! Thank you for your feedback.
|
Simple solution, thank you very much.
Στις 9:49 μ.μ. Τετάρτη, 23 Αυγούστου 2017, ο/η Gregory Demin <notifications@github.com> έγραψε:
Hi! Thank you for your feedback.
I will try to fix this issue in the future version. Generally speaking, value labels on factors give undefined behavior because variables with value labels and factors both have labels and there is no obvious way of combining factor's labels with additional labels applied with val_lab. It's better do not apply value labels on factors in your workflow.
So, your code will be (note the absence of factor):gender = c(1, 1, 1, 0, 0, 0, 1, 0, 0, 0,
1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1,
0, 0, 1, 0, 1, 1, 1, 1, 1, 0)
group = c(rep(1, 10), rep(2, 11), rep(3, 10))
sample.df = data.frame(group, gender)
library(expss)
sample.df = apply_labels(sample.df,
gender = "Gender",
group = "Group")
val_lab(sample.df$group) = num_lab("1 A
2 B
3 C")
val_lab(sample.df$gender) = num_lab("0 Women
1 Men")
cro_cases(sample.df$group, sample.df$gender)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Congratulations for your efforts on your excelent package.
It seems that cro_cases does not function properly when labels are previously attached to the variables (using val_lab).
Code to reproduce:
try without value labels: functioning ok:
try with value labels: functioning not ok:
The problem appears when value labels are defined at column variable (gender in the above example). Value labels at the row variable as well as presence or not of the labels at the variables are irrelevant.
The text was updated successfully, but these errors were encountered: