Challenge - 5 Problems
Label and Title Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this plot title code?
Consider the following R code that creates a simple plot with a title and axis labels. What will be the title of the plot when this code runs?
R Programming
plot(1:5, 1:5, main = "My Plot Title", xlab = "X Axis", ylab = "Y Axis") title(main = "Overridden Title")
Attempts:
2 left
💡 Hint
The title() function can override the main title set in plot().
✗ Incorrect
The plot() function sets the initial main title to "My Plot Title". The subsequent title() call with main = "Overridden Title" replaces the main title on the plot.
❓ Predict Output
intermediate2:00remaining
What label appears on the x-axis?
What label will appear on the x-axis after running this R code?
R Programming
barplot(1:3, names.arg = c("A", "B", "C"), xlab = "Category")
Attempts:
2 left
💡 Hint
xlab sets the label for the x-axis, names.arg sets the names for bars.
✗ Incorrect
The xlab argument sets the label for the x-axis, so "Category" will appear as the x-axis label. The names.arg argument labels each bar but does not change the axis label.
🔧 Debug
advanced2:00remaining
Why does this plot title not appear?
This R code is intended to add a title to the plot, but no title appears. What is the cause?
R Programming
plot(1:10, 1:10) title(main = "My Title", sub = "Subtitle") title(xlab = "X Label")
Attempts:
2 left
💡 Hint
Check which arguments title() accepts and which must be set in plot().
✗ Incorrect
The title() function accepts main, sub, and line arguments but does not accept xlab or ylab. Axis labels must be set in the plot() function or with separate axis labeling functions.
🧠 Conceptual
advanced2:00remaining
How to add multiple lines in a plot title?
Which option correctly adds a multi-line main title to a plot in R?
Attempts:
2 left
💡 Hint
Use newline characters in strings or multiple calls to title().
✗ Incorrect
The newline character \n inside a string works in title() to create multi-line titles. The main argument in plot() does not interpret \n properly for multi-line titles, so using title() after plot() is the correct approach.
❓ Predict Output
expert3:00remaining
What is the output of this label and title code?
What will be the main title and axis labels of the plot after running this R code?
R Programming
plot(1:3, 1:3, main = "First Title", xlab = "X1", ylab = "Y1") title(main = "Second Title", xlab = "X2") title(ylab = "Y2")
Attempts:
2 left
💡 Hint
title() can override main and sub titles but not axis labels; check which labels are updated.
✗ Incorrect
The first title() call overrides the main title. However, title() does not accept xlab or ylab arguments, so axis labels remain as set in plot(). The second title() call with ylab is ignored. So the final labels are main = "Second Title", xlab = "X1", ylab = "Y1".