Skip to content
New course: Interactive Dashboards with Shiny. Get 50% off with coupon SHINYLAUNCH.
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

Complete the crosstabs sections of the data-wrangling-and-analysis-exercises.Rmd file. Make sure that you have the janitor package installed (if not, use the install.packages function) and loaded (use the library function).

Learn More

The janitor package has a great vignette with information about the tabyl and adorn_ functions.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Daniel Sossa

Daniel Sossa

March 14, 2021

I noticed that the rendered table you get when knitting after adding a third variable is not the same you get when doing only two (it is only text, not the nice table format). Is there a way to get the same type of table rendered?

David Keyes

David Keyes

March 16, 2021

Alright, so this is not my strongest area, but I tried to explain this a bit in this video. Hope it helps!

Vuk Sekicki

Vuk Sekicki

March 29, 2021

This video does not have sound. Tnx

David Keyes

David Keyes

March 29, 2021

Oops, sorry! I'll re-record later today.

David Keyes

David Keyes

March 30, 2021

Ok, the video linked now from the comment above is updated. Hope it helps!

Abby Isaacson

Abby Isaacson

March 31, 2021

I had this same question, thanks for addressing it (even though it makes me want to avoid that for now!).

Jyoni Shuler

Jyoni Shuler

March 26, 2021

To solve the error message and remove the N/As, would we use the 'drop_na' function then?

David Keyes

David Keyes

March 29, 2021

Yup, that works! You can run that before doing the crosstab, which will get rid of any missing values and thus should get rid of the error message.

Tatiana Bustos

Tatiana Bustos

July 28, 2022

For the last coding solution - what do the $ indicate next to the age_decade? Will this show up in the table in the final report (once we convert to word or other)? Is there a way to remove that and just show the actual age_decade labels?

David Keyes

David Keyes

July 29, 2022

I'm not sure exactly why there is a $, but it will show up in your Word document when you knit. To be honest, I don't use the tabyl() functions for final outputs that I would share with others, just for exploring the data on my own when starting out. As a result, I don't care that much about having the ugly $.

Is there a way to show both column & row percentages using tabyl? Or is there another crosstab function that could do this? (I'm thinking similar to a proc freq in SAS, which has frequency, percent, column percent and row percent for each cell)

David Keyes

David Keyes

October 6, 2022

I believe the adorn_percentages() function should do this, unless I'm missing something about your question.

Hi David! I figured it out, I just had to mess with the denominator to get what I was looking for: adorn_percentages(denominator = "col")

Thanks!

David Keyes

David Keyes

October 6, 2022

Great!