Skip to content
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

tabyl() suggestion: NA options - specify NA label or values to treat as NA #350

Open
jzadra opened this issue Mar 30, 2020 · 2 comments
Open

Comments

@jzadra
Copy link
Contributor

jzadra commented Mar 30, 2020

I was thinking about doing a PR for tabyl that would enhance handling of NA.

Currently if a variable has NAs, and show_na = T you get a line in the tabyl with <NA> and an extra valid_percent column (which is awesome!).

  1. Would it be useful to allow an argument to re-lable the row in the tabyl? ie na_label = "Missing" or na_label = "Did not respond"?

  2. Would it be useful to allow for specifying that one or more values are to be treated in the same way that NAs are currently treated in 1-way tables so that they are not counted for the valid_percent? For isntance, if I Have data that has both NAs and a value like "Skipped" (in my data, this is when a person sees a question on a survey but doesn't respond, as opposed to the NA when the question isn't displayed perhaps based on logic flow of the survey). So you'd still get separate rows for "Skipped" and "NA", but neither would be counted in valid_percent.

@sfirke
Copy link
Owner

sfirke commented Nov 24, 2020

Thanks for these ideas. I get the appeal of (2) but the argument wouldn't apply to a two-way tabyl, yet it would be added to the function call for tabyl generally for what I think is too-niche an application.

For (1), that's interesting - because I think it would apply to a two-way tabyl, too, which has NA. Having those say a user-specified value like "Missing" could make the result more polished. Right now I would see the analyst needing one line to change this manually for the 1-way tabyl and two lines for a 2-way. The question is, does the convenience of avoiding those lines justify adding another argument to tabyl for something that's relatively minor? I'm not sure.

@sfirke
Copy link
Owner

sfirke commented Dec 9, 2021

What if you could pass a string to show_na and that would replace the NA_ with that string? Then it doesn't add an argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants