0
0
R Programmingprogramming~5 mins

ggplot() and aes() basics in R Programming - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of ggplot() in R?

ggplot() creates a blank canvas for making plots. It sets up the space where you add layers like points, lines, or bars.

Click to reveal answer
beginner
What does aes() do inside ggplot()?

aes() stands for aesthetics. It tells ggplot() which data columns to use for x-axis, y-axis, colors, sizes, and other visual parts.

Click to reveal answer
beginner
How do you map the variable height to the y-axis using aes()?

You write aes(y = height) inside ggplot() or a layer to tell ggplot to use the height data for the vertical axis.

Click to reveal answer
intermediate
Can you add multiple aesthetics inside aes()? Give an example.

Yes! You can map many things. For example, aes(x = age, y = height, color = gender) maps age to x-axis, height to y-axis, and colors points by gender.

Click to reveal answer
intermediate
What happens if you put aes() inside ggplot() vs inside a layer like geom_point()?

Inside ggplot(), aesthetics apply to all layers. Inside a layer, they apply only to that layer. This helps control what data each layer uses.

Click to reveal answer
What does ggplot(data, aes(x = var1, y = var2)) do?
AFilters data where var1 equals var2
BCreates a table with var1 and var2
CSets up a plot using var1 on x-axis and var2 on y-axis
DSaves a plot to a file
Which function defines how data columns map to visual parts in ggplot?
Ageom_point()
Baes()
Cfilter()
Dsummary()
If you want to color points by a variable group, where do you put color = group?
AInside aes()
BOutside aes()
CInside ggplot() but not aes()
DInside geom_point() but not aes()
What does geom_point() add to a ggplot?
AA title to the plot
BLines connecting points
CA legend
DPoints (dots) to the plot
Where do you put aes() if you want different layers to use different mappings?
AInside each layer separately
BOnly inside ggplot()
COutside ggplot() and layers
DInside the data frame
Explain how ggplot() and aes() work together to create a plot.
Think of ggplot as the canvas and aes as the instructions for what to draw.
You got /4 concepts.
    Describe how you would map three variables: one to x-axis, one to y-axis, and one to color in a ggplot.
    Remember aes() can take multiple arguments for different aesthetics.
    You got /3 concepts.