In R, creating visualizations using base graphics is an essential skill for data analysis. Mastering plotting functions such as histograms, scatterplots, and barplots, along with graph customization, empowers analysts to present insights effectively.
1. Introduction to Base R Graphics
Which function is used to create a simple plot in Base R? a) plot() b) ggplot() c) hist() d) barplot()
In Base R, what is the default plotting device used? a) Graphical Device b) Plot Window c) RGraphics d) Ggplot Device
What does the plot() function in R do by default? a) Creates a scatter plot b) Creates a line plot c) Creates a histogram d) Creates a bar plot
Which argument in the plot() function controls the type of plot? a) plot.type b) type c) graph.type d) chart.type
How do you add a title to a plot in R? a) title() b) addTitle() c) plotTitle() d) legend()
Which function is used to create a histogram in Base R? a) hist() b) barplot() c) scatterplot() d) plot.hist()
Which graphical parameter is used to change the background color of a plot in R? a) bg b) col.bg c) background d) color.bg
In Base R graphics, how do you change the axis labels of a plot? a) axis.labels() b) xlabel() and ylabel() c) xlab() and ylab() d) axes()
What does the xlim argument control in a Base R plot? a) The limits of the x-axis b) The limits of the plot window c) The labels on the x-axis d) The color of the x-axis
Which function allows adding a legend to a plot in Base R? a) addLegend() b) legend() c) addLabels() d) legendTitle()
Which function is used to create a scatter plot in Base R? a) scatterplot() b) plot() c) xyplot() d) bubbleplot()
What is the default plot type for the plot() function? a) Line plot b) Histogram c) Bar plot d) Scatter plot
Which function is used to create a bar plot in R? a) barplot() b) bar() c) plot.bar() d) bar_graph()
How do you create a boxplot in R using Base graphics? a) plot.box() b) box() c) boxplot() d) plotBox()
Which argument in the hist() function specifies the number of bins for a histogram? a) bins b) breaks c) segments d) categories
How do you change the color of bars in a bar plot in R? a) col.bar b) bar.colors c) col d) fill.color
Which function would you use to add a horizontal line to a plot? a) abline() b) hline() c) addline() d) line()
How do you create a stacked bar plot in R? a) Use the barplot() function with the beside = FALSE argument b) Use stacked.barplot() c) Use hist() with the stack = TRUE argument d) Use plot() with the type = "stack" argument
Which of the following arguments can be used to adjust the size of points in a scatter plot? a) pch b) cex c) size d) points.size
How do you add grid lines to a Base R plot? a) grid() b) addGrid() c) gridlines() d) addGridlines()
3. Customizing Graphs
Which argument is used to modify the title size in a plot in R? a) title.size b) cex.main c) main.size d) title.text
How can you change the color of the plot’s points in Base R? a) pch b) col c) color.points d) point.color
How do you change the line type in a Base R plot? a) type.line b) lty c) line.type d) plot.line
What argument in plot() can be used to change the plot’s background color? a) bg b) plot.bg c) background.color d) col.bg
How can you add text to a specific point on a plot in R? a) text() b) addText() c) plotText() d) label()
Which argument in hist() allows you to set the appearance of the histogram’s bars? a) style b) col c) fill d) color.bar
How do you specify the range of the y-axis in a plot in R? a) ylim b) y.range c) yaxis.range d) axis.y
How do you create a plot with no axes in Base R? a) axes = FALSE b) noaxes = TRUE c) plot() without specifying axes d) plot(axes = FALSE)
Which argument in the barplot() function controls the width of the bars? a) bar.width b) width c) density d) space
How can you add a custom axis to a plot in R? a) customAxis() b) axis() c) addAxis() d) plot.axis()
Answers Table
QNo
Answer (Option with Text)
1
a) plot()
2
b) Plot Window
3
a) Creates a scatter plot
4
b) type
5
a) title()
6
a) hist()
7
a) bg
8
c) xlab() and ylab()
9
a) The limits of the x-axis
10
b) legend()
11
b) plot()
12
d) Scatter plot
13
a) barplot()
14
c) boxplot()
15
b) breaks
16
c) col
17
a) abline()
18
a) Use the barplot() function with the beside = FALSE argument