D. coord_flip() should be replaced with coord_cartesian()
Solution
Step 1: Check arguments accepted by coord_flip()
coord_flip() flips axes but does not accept ratio argument.
Step 2: Identify correct way to set aspect ratio when flipping
Aspect ratio should be set using coord_fixed(), not inside coord_flip().
Final Answer:
coord_flip() does not accept ratio argument -> Option B
Quick Check:
coord_flip() has no ratio argument [OK]
Hint: coord_flip() does not accept ratio argument [OK]
Common Mistakes:
Trying to set ratio inside coord_flip()
Confusing coord_flip() with coord_cartesian()
Assuming geom_point() needs extra arguments
5. You want to create a pie chart in ggplot2 using coord_polar(). Which coordinate system transformation should you apply before coord_polar() to make the pie chart correctly represent proportions?
hard
A. Use geom_point() with coord_polar()
B. Use geom_bar() with stat = 'identity'
C. Use geom_bar() with default settings and map fill to factor variable
D. Use geom_line() with coord_polar()
Solution
Step 1: Understand pie chart creation in ggplot2
Pie charts are created by using bar charts with polar coordinates.
Step 2: Identify correct geom and mapping
Using geom_bar() with default settings and mapping fill to a factor variable creates bars representing counts, which coord_polar() converts to pie slices.
Final Answer:
Use geom_bar() with default settings and map fill to factor variable -> Option C
Quick Check:
Pie chart = geom_bar() + coord_polar() with fill mapped [OK]
Hint: Pie charts use geom_bar() + coord_polar() with fill mapped [OK]
Common Mistakes:
Using geom_point() or geom_line() which don't create bars
Setting stat='identity' unnecessarily for counts
Not mapping fill to a factor variable
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.