Get access to all lessons in this course.
-
RMarkdown
- Why Use RMarkdown?
- RMarkdown Overview
- YAML
- Text
- Code Chunks
- Wrapping Up
-
Data Wrangling and Analysis
- Getting Started
- The Tidyverse
- select
- mutate
- filter
- summarize
- group_by
- count
- arrange
- Create a New Data Frame
- Crosstabs
- Wrapping Up
-
Data Visualization
- An Important Workflow Tip
- The Grammar of Graphics
- Scatterplots
- Histograms
- Bar Charts
- color and fill
- scales
- Text and Labels
- Plot Labels
- Themes
- Facets
- Save Plots
- Wrapping Up
-
Wrapping Up
- You Did It!
Fundamentals of R
color and fill
This lesson is locked
This lesson is called color and fill, part of the Fundamentals of R course. This lesson is called color and fill, 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 color and fill sections of the data-visualization-exercises.Rmd file.
Learn More
color and fill Resources
You may want to review Chapter 3 from R for Data Science , which includes a section on mapping data to color and fill aesthetics. Chapter 2 of Fundamentals of Data Visualization has a similar discussion. So does Chapter 3 of Data Visualization: A Practical Introduction.
You need to be signed-in to comment on this post. Login.
Atlang Mompe
April 4, 2021
Hi David, when you do the coord_flip() - can you order the data into ascending or descending by the variable? If so, could you kindly show us how to do so? So for the age_decade by height - what if I wanted to see the tallest age_decade to the shortest age_decade, what would the code look lik?
Thank you, Atty
David Keyes
April 5, 2021
The easiest way for me to explain this is to point you to this lesson from the Going Deeper course. Long story short: you need to use factors in order to determine order of plots. It's slightly confusing because you use
arrange()
for tables, but that doesn't work to order plots. Here's an explanation video.Kateryn Pino
April 7, 2021
Hi David, In this exercise, Can I drop NAs in the same ggplot code, or I necessarily have to do some data wrangling first? Thanks!
David Keyes
April 8, 2021
You could either remove them by doing some wrangling before plotting or you could use the na.value argument in several scale functions (e.g.
<a href="https://ggplot2.tidyverse.org/reference/scale_brewer.html" rel="nofollow ugc">scale_brewer()</a>
).Elan Sykes
October 6, 2021
At this point in the exercise file, my code stopped automatically indenting and the function help tooltips stopped appearing. The commented lines in the code chunk also appear in blue instead of green here. I'm not sure what I did to cause this, and I got the code to work by indenting myself, but it takes a lot longer when it's not running automatically. Did I mess something up that I can change back easily?
David Keyes
October 6, 2021
Can you please post your code as a Gist and share the link?
Elan Sykes
October 6, 2021
https://gist.github.com/ensykes/94f95665a0f2c52048cc08faa7619ae4
David Keyes
October 6, 2021
I see the issue! Look right above the #
color
andfill
first-level header. You have an extra triple backtick. That's making things stop working. Delete that and you should be good to go.Elan Sykes
October 6, 2021
Thank you!!