Ask questionsUsing tabyl with index-numbers

Feature requests

I would like to use tabyl for recurring procedures with a map()-function, looping over several variables in a data frame without naming them, but rather just have the loop access the next variable in line. It is possible with table(), but I don't like table()'s properties and rather do it with tabyl().

Here is an example with table():

map(mtcars[1:6], function(x) table(x,mtcars$gear))

With tabyl I would have to specify each tabulation, correct?

tabyl(mtcars, mpg, gear)
tabyl(mtcars, cyl, gear)
# etc.
tabyl(mtcars, wt, gear)

That seems tedious to me and I would prefer a looping-solution.


Answer questions sfirke

It might be from the rlang package? I'm not really sure how to help further since it's not a janitor-related issue, sorry.

You might try posting a question on StackOverflow for help.


On Thu, Jun 24, 2021, 7:19 PM RachelK1994 ***@***.***> wrote:

Thank you very much for getting back to me @sfirke! I've tried this but unfortunately I then get the message, " Error in :=(!!varname, value) : could not find function ":="" - is it just the "dplyr" package I need to read in or is there perhaps another package I'm missing (or perhaps I've loaded another redundant package that is causing the issue)? Best,Rachel

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe .


Related questions

No questions were found.
Sam Firke sfirke City of Ann Arbor Ann Arbor, MI Data scientist, caring human. Currently focused on municipal data analysis and business intelligence.
Github User Rank List