Base R includes plot(), hist(), and boxplot()—quick exploratory charts without extra packages. The playground can run simple base plots; output may appear in local graphics devices.
Scatter and line
x <- c(1, 2, 3, 4)
y <- c(2, 4, 3, 5)
plot(x, y, main = "Scores", xlab = "Week", ylab = "Value")
Histogram
vals <- c(10, 12, 14, 18, 23, 25)
hist(vals, main = "Distribution", col = "steelblue")
Base plots are imperative—each call draws on the active device. ggplot2 (local) uses a grammar of layers instead.
Important interview questions and answers
- Q: plot() vs ggplot2?
A: base plot() is quick and built-in; ggplot2 builds layered grammar-of-graphics charts locally. - Q: Graphics in Rscript?
A: Scripts may need png()/pdf() devices locally; playground focuses on data prep and print summaries.
Self-check
- What function draws a histogram in base R?
- Name two plot arguments for axis labels.
Tip: Base plot() works offline; save with png() locally when you need files.
Interview prep
- plot vs hist?
plot(x,y)scatter/line;hist()distribution of one variable.