Get access to all lessons in this course.
- Welcome to Fundamentals of R
- Update Everything
- Start a New Project
-
Data Wrangling and Analysis
- The Tidyverse
- Pipes
- select()
- mutate()
- filter()
- summarize()
- group_by() and summarize()
- arrange()
- Create a New Data Frame
- Bring it All Together (Data Wrangling)
-
Data Visualization
- The Grammar of Graphics
- Scatterplots
- Histograms
- Bar Charts
- Setting color and fill Aesthetic Properties
- Setting color and fill Scales
- Setting x and y Scales
- Adding Text to Plots
- Plot Labels
- Themes
- Facets
- Save Plots
- Bring it All Together (Data Visualization)
-
Quarto
- Quarto Overview
- YAML
- Text
- Code Chunks
- Tips for Working with Quarto
- Bring It All Together (Quarto)
-
Wrapping Up
- An Important Workflow Tip
Fundamentals of R
Histograms
This lesson is locked
This lesson is called Histograms, part of the Fundamentals of R course. This lesson is called Histograms, part of the Fundamentals of R 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 histogram sections of the data-visualization-exercises.Rmd file.
Learn More
Histogram Resources
You can find examples of code to make histograms on the Data to Viz website , the R Graph Gallery website , and in Chapter 6 of the R Graphics Cookbook , and Chapter 7 of the Fundamentals of Data Visualization.
To learn about more statistical transformations, Chapter 3 of R for Data Science has a discussion of them.
You need to be signed-in to comment on this post. Login.
Atlang Mompe
April 5, 2021
Hi David, I don't think I quite understand bins - as when the graph changes from bins =100 to bins =10, I thought the x axis would change, so what exactly is being group? Thank you for the further clarification. Atty.
David Keyes
April 5, 2021
The x axis doesn't change because the range of data plotted on the x axis doesn't change, it's just the number of buckets we put it into that does. Does that help? This overview of how histograms work might also be helpful to you.
Kateryn Pino
April 8, 2021
Hi David, everything is ok. Just this message appears... Removed 78 rows containing non-finite values (stat_bin). What is that mean?
David Keyes
April 8, 2021
Great question! It means that there were 78 observations that had NA for the weight variable so they were not included in the plot. Nothing went wrong, it's just an informational message.
Kateryn Pino
April 15, 2021
Thanks David!
Louise Blight
April 9, 2021
There's an informational pop-up in the exercises file (at line 63 in my code) that reads "
stat_bin()
usingbins = 30
. Pick better value withbinwidth
". Should this readbins
instead ofbinwidth
? I tried the latter and it seems to code for the actual width of the bins - no surprise I guess - instead of the number of bins we're adjusting in this exercise.David Keyes
April 10, 2021
You can actually do both! To be honest, I'm not super great with the rationale for why you'd want to do one or another, but try them both and see what happens!