1
In ggplot2, what function is used to create a scatter plot?
A)
geom_scatter()
B)
scatter()
C)
geom_point()
D)
point()
Answer & Solution
Answer: Option
C
2
How do you change the color of all points in a ggplot2 scatter plot to red?
A)
color = "red"
B)
fill = "red"
C)
col = "red"
D)
aes(color = "red")
Answer & Solution
Answer: Option
A
3
In ggplot2, what is the purpose of the aes() function?
A)
Adds aesthetic mappings to the plot
B)
Adjusts the axis labels and titles
C)
Applies statistical transformations to the data
D)
Sets the color of the entire plot
Answer & Solution
Answer: Option
A
4
What is the purpose of the ggtitle() function in ggplot2?
A)
Sets the title of the entire plot
B)
Adds a title to a specific layer of the plot
C)
Adds a title to the legend
D)
Adjusts the size of the title text
Answer & Solution
Answer: Option
A
5
How do you create a bar plot in ggplot2 for a categorical variable named category and its counts?
A)
geom_bar(x = category, y = count)
B)
geom_bar(mapping = aes(x = category, y = count))
C)
geom_bar(aes(x = category, y = count))
D)
bar_plot(category, count)
Answer & Solution
Answer: Option
C
6
In ggplot2, what function is used to create a line plot?
A)
geom_line()
B)
line()
C)
geom_path()
D)
path()
Answer & Solution
Answer: Option
A
7
How do you add error bars to a ggplot2 bar plot?
A)
geom_error_bars()
B)
error_bar()
C)
geom_errorbar()
D)
bar_error()
Answer & Solution
Answer: Option
C
8
What is the role of the facet_wrap() function in ggplot2?
A)
Creates a scatter plot with wrapped facets
B)
Divides the plot into multiple facets
C)
Adds a wrap-around border to the plot
D)
Creates a ribbon-like effect in the plot
Answer & Solution
Answer: Option
B
9
In ggplot2, what is the purpose of the theme() function?
A)
Adjusts the overall theme of the plot
B)
Changes the color theme of specific elements
C)
Sets the font size of the plot
D)
Adds a theme to a specific layer of the plot
Answer & Solution
Answer: Option
A
10
How do you create a boxplot in ggplot2 for a numerical variable named value grouped by a factor variable group?
A)
geom_boxplot(x = group, y = value)
B)
box_plot(group, value)
C)
geom_boxplot(mapping = aes(x = group, y = value))
D)
geom_boxplot(aes(x = group, y = value))
Answer & Solution
Answer: Option
C