Skip to content
R for the Rest of Us: A Statistics-Free Introduction comes out June 25th. Or you can read the online version today. Check it out →
R for the Rest of Us Logo

Pipe Data Into ggplot

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

  1. Create a new RMarkdown document

  2. Create a data frame called enrollment_by_race_ethnicity by reading in your race/ethnicity data from the data wrangling and analysis section using the read_rds() function

  3. Pipe your data into a bar chart that shows the breakdown of race/ethnicity among students in Beaverton SD 48J in 2018-2019

Your chart should look like this:

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

May 7, 2021

I can't seem to load the rds file and I'm not sure why. The data and RMarkdown file are saved in the Oregon Schools project. Here is my code and error message:

enrollment_data <- 
  read_rds("/data/enrollment_race_ethnicity.rds")

Error in gzfile(file, "rb") : cannot open the connection In addition: Warning message: In gzfile(file, "rb") : cannot open compressed file '/data/enrollment_race_ethnicity.rds', probable reason 'No such file or directory'

Atlang Mompe

Atlang Mompe

June 23, 2021

I run this code and get this error message, what am I doing wrong?

enrollment_by_race_ethnicity %>% 
  filter(district == "Beaverton SD 48J") %>% 
  filter(year == "2018-2019") %>% 
  ggplot(aes(x = percent_of_total_at_school,
             y = race_ethnicity)) +
  geom_col()

Error in filter(., district == "Beaverton SD 48J") : object 'enrollment_by_race_ethnicity' not found

Please advise - I was able to read the rds data and I can see it in the environment pane, but when I use the same code that you shared, I get an error, it says object not found, even though I can see the data on the environment frame.

Mychal Davis

Mychal Davis

May 19, 2022

Hello,

Which week did we make the RDS file that we are supposed to use for this assignment?

Thank you, Mychal

Hi -

I get the x-y axis (labeled appropriately) but no data plotted......and no error messages.....

Ruimin Xu

Ruimin Xu

May 30, 2023

Hi David, I got blank chart when running below code... Not sure what is wrong enrollment_by_race_ethinicity %>% filter(year=="2018_2019") %>% filter(district=="Beaverton SD 48J") %>% mutate(percent_of_total_at_school=percentage_of_students) %>%

view()

ggplot(aes(x=percent_of_total_at_school,y=race_ethinicity)) geom_col()