Skip to content
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

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 bar chart sections of the data-visualization-exercises.Rmd file.

Learn More

Bar Chart Resources

You can also find examples of code to make bar charts on the Data to Viz website , the R Graph Gallery website , and in Chapter 3 of the R Graphics Cookbook. Michael Toth also has a detailed blog post about making bar charts with ggplot.

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

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

Allison Brenner

Allison Brenner

March 25, 2021

I keep getting an error message "attempt to use zero-length variable name". When I get this it's usually some small thing I missed, but I missed things last week and didn't get this message. I'm wondering why I'm seeing this now, and what exactly it means. Also, suddenly I don't get R Studio's automatic prompts when I begin writing a command. For example, when I start "summarise(" it doesn't prompt with the options for the command. Any ideas why I might be experiencing these changes? I have started a new R session and changed the defaults as you indicated in the lessons, but otherwise haven't made any intentional changes in how I am using R.

Nithin Pradeep

Nithin Pradeep

October 7, 2021

Hii David, I have a survey dataset with me. The survey has got 4 sections. I want the data to be visualised in such a way that I have "Male" and "Female" in the x-axis and the average sectional scores on y-axis. Can you help me with this?

Nadia Chang

Nadia Chang

October 13, 2022

For this exercise I gave the data frame and the new variable the same name, but I got the same result. Why this happened? could this give you any trouble later? But I see it's better to give different names.

sleep_by_gender % 
  group_by(gender) %>% 
  summarize(sleep_by_gender = mean(sleep_hrs_night, 
                                   na.rm = TRUE))

I noticed the code works without putting "mapping=" before aes--is this a bad habit to leave it out? This worked for me:

nhanes %>% ggplot(aes (x=smoke_now)) + geom_bar()