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() should further clean variable names that it returns #43

Closed
sfirke opened this issue Jul 18, 2016 · 4 comments
Closed

tabyl() should further clean variable names that it returns #43

sfirke opened this issue Jul 18, 2016 · 4 comments

Comments

@sfirke
Copy link
Owner

sfirke commented Jul 18, 2016

For instance tabyl(nchar(combined$Associate's Year Awarded)) yields:

   nchar(combined_`Associate's Year Awarded`)     n      percent valid_percent
                                        <int> <int>        <dbl>         <dbl>
1                                           1     1 8.212203e-05    0.01388889
2                                           3     9 7.390983e-04    0.12500000
3                                           4    27 2.217295e-03    0.37500000
4                                           5    29 2.381539e-03    0.40277778
5                                           9     1 8.212203e-05    0.01388889
6                                          11     2 1.642441e-04    0.02777778

IMO that should be combined_Associates_Year_Awarded for easier subsequent reference

@sfirke
Copy link
Owner Author

sfirke commented Jul 25, 2016

Eh, it's unclear. If you're doing further operations on the result, like a join, this is an advantage. But, you should call clean_names() now, or should have called it before tabyl(). So it's kind of hand-holdy.

If you're not doing further operations, and are just printing to console, then the status quo is more useful in that it confirms what you did. And if you're printing it in a markdown table, you'll probably need to tweak the name anyway.

It's easy to add a clean_names call to the tabyl() function but I'm not sure it's worth it.

@sfirke
Copy link
Owner Author

sfirke commented Sep 8, 2016

I'm fine with retaining the dirty name, like:

mtcars %>% mutate(`bad name` = cyl) -> k
tabyl(k$`bad name`)

But unfortunate that this:

mtcars %>% mutate(`bad name` = cyl) %>% tabyl(`bad name`)

Gives "bad.name" instead of "bad name".

@sfirke
Copy link
Owner Author

sfirke commented Sep 8, 2016

Oh and this behavior (default and piped) should match that of crosstab()

@sfirke
Copy link
Owner Author

sfirke commented Sep 8, 2016

Fixed - now piped calls to both functions will return exactly the variable name, with whatever warts it has, and default calls will return the data.frame name and $, e.g., mtcars$cyl or mtcars$bad name``.

@sfirke sfirke closed this as completed in bf3d274 Sep 8, 2016
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

1 participant