Data Visualization with R
- 64Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
Why is the Titanic dataset useful for teaching data analysis to audiences from varied backgrounds?
The Titanic story is widely familiar, so people can focus on the analysis without first learning an unfamiliar problem domain.
Or swipe the card
64 cards
Why is the Titanic dataset useful for teaching data analysis to audiences from varied backgrounds?
The Titanic story is widely familiar, so people can focus on the analysis without first learning an unfamiliar problem domain.
Why can the Titanic dataset serve as a proxy for business customer-profile data?
Its data resembles customer-profile data and includes common real-world issues such as missing values and columns with overloaded meanings.
How large was the Titanic dataset used in the tutorial?
It contained 891 observations and 12 columns.
What does the
survivedvariable represent?A binary indicator: 0 means the passenger died, and 1 means the passenger survived.
What does
pclassrepresent, and what values can it take?The passenger’s ticket class or accommodation level: first, second, or third class, represented by 1, 2, or 3.
What does the
sexvariable record?Whether a passenger was male or female.
What kind of variable is passenger age in this dataset?
A continuous numeric variable; ages can include decimal values.
What does
sibspcount, and why is its meaning overloaded?It records the number of siblings and/or a spouse traveling with a passenger, combining more than one relationship type in one column.
What does
parchcount, and why is its meaning overloaded?It records the number of parents and/or children traveling with a passenger, combining more than one relationship type in one column.
What information is stored in the
ticketvariable?The passenger’s ticket serial number.
What does the
farevariable measure, and in what currency?The amount paid for a ticket, in pound sterling.
What does the
cabinvariable contain?A passenger’s cabin number, when one was assigned; not every passenger had one.
What does the
embarkedvariable record?The port where a passenger boarded: C for Cherbourg, Q for Queenstown, or S for Southampton.
What was the consulting analysis of the Titanic dataset intended to explain?
Patterns in which passengers survived or died, for an audience that was not highly data-savvy.
Why should
PassengerIdgenerally be excluded from this analysis?It is a unique identifier that increases by row and does not provide useful analytical signal about survival.
Why were passenger names excluded from the tutorial’s analysis?
All names were unique, so they offered no direct analytical signal in their existing form. Text analysis might extract signal, but that was outside the tutorial’s scope.
Why should
survivedbe treated as a categorical variable rather than a numeric one?Its values label two outcomes; arithmetic such as multiplying or dividing them is not meaningful.
Why should
pclassbe treated as categorical rather than ratio-scale numeric data?The class numbers label accommodation categories: third class is not three times first class, and first class is not one-third of third class.
Why are
sexandembarkedcategorical variables?Their values identify distinct groups—male/female and the different embarkation ports—rather than quantities for arithmetic.
What practical heuristic can help distinguish numeric quantities from categorical labels?
Ask whether multiplication or division of the values would make sense. If not, the values may be categories rather than ratio-scale quantities.
What can ggplot2 do with a categorical variable mapped to an aesthetic such as fill?
It can use the categories to distinguish groups visually, for example by assigning different colors.
How does ggplot2 handle missing values when creating a plot?
It can omit rows with missing values for the plotted data and issue a warning; in the age examples, it removed 177 missing ages.
What are the six components of the grammar of graphics described for ggplot2?
Data, layers, scales, coordinates, faceting, and themes.
What role does data play in a ggplot2 visualization?
It is the raw material from which the visualization is constructed.
What are layers in a ggplot2 graphic?
The visual elements shown in the plot, such as points, lines, or bars.
What is the role of scales in the grammar of graphics?
Scales map or adjust data values so they can be represented consistently within the limited space of a graphic.
What do coordinates determine in a ggplot2 visualization?
The visualization’s spatial perspective. The usual default is a two-dimensional x-y grid, though other coordinate systems are available.
What is faceting used for in ggplot2?
To divide data into subsets and show them in separate panels, enabling visual drill-down across categories.
What kinds of plot properties can themes control?
Display details such as fonts, font sizes, colors, and overall look and feel.
Do you need to customize every component of the grammar to begin using ggplot2?
No. Defaults work well for many plots; deeper control is available when a graphic needs customization.
How does ggplot2 combine ease of use with fine-grained control?
It can produce polished graphics with little code, while its grammar and functions also allow detailed customization.
What is an aesthetic mapping in ggplot2?
An instruction that maps data variables to visual properties, such as assigning a variable to the x-axis or to fill color.
What does a
geomfunction specify?The type of visual layer to draw, such as bars or a histogram.
What is one practical advantage of ggplot2’s design for producing graphics?
It can create high-quality, print-suitable graphics quickly, while still allowing detailed control when needed.
What three ingredients are generally needed to create a basic ggplot2 graphic?
Data, aesthetic mappings, and a layer specifying what to draw.
What does
ggplot()establish when constructing a plot?The foundation of a ggplot object, including the data to use and any initial aesthetic mappings.
How would you map passenger age to the y-axis in ggplot2?
Specify an aesthetic mapping that assigns the age variable to the y-axis.
Why must a plot specify a layer?
Without a layer, ggplot2 has no instruction about which visual marks—such as bars, lines, or points—to display.
Why is a bar chart useful for a categorical variable such as survival status?
It displays counts for each category, a straightforward way to summarize categorical data.
How can you recognize many ggplot2 geometry functions in R code?
Their names commonly begin with
geom_, such asgeom_bar()orgeom_histogram().How can copy-and-paste reuse make repeated ggplot2 analyses more efficient?
Start with a working plot, copy its code, and change only the mappings or labels needed for the next question.
What are
labs()and a theme useful for when refining a plot?labs()can change axis and plot labels; a theme can adjust appearance, such as replacing a gray background with a white one.What overall survival proportions did the Titanic survival bar chart show?
Approximately 62% of passengers died and 38% survived.
What question does mapping survival status to the x-axis and using a bar layer answer?
How many passengers fell into each survival category.
What survival pattern appeared when passengers were compared by sex?
Females survived disproportionately more often, while most males did not survive.
What did the sex-based survival chart suggest about the passenger mix?
There were approximately twice as many male passengers as female passengers.
What does mapping survival status to
filladd to a sex-based bar chart?It color-codes the survival outcomes within each sex category, making their relative proportions easier to compare.
How did survival differ across ticket classes in the class-based bar chart?
More than half of first-class passengers survived, second class was around half, and third class was around one-quarter.
What unexpected passenger-count pattern appeared across ticket classes?
Second class had fewer passengers than either first or third class.
How can faceting by ticket class help analyze survival by sex?
It creates a separate panel for each class, allowing sex-based survival patterns to be compared within each class.
What pattern did the class-and-sex panels show for female passengers?
Females in first and second class overwhelmingly survived; female survival in third class was closer to an even split.
What pattern did the class-and-sex panels show for male passengers?
Male survival was much lower overall; first-class males had the highest survival among males, while third-class males had the lowest.
What does the bin width control in a histogram?
The width of the intervals used to group numeric observations. Changing it changes the histogram’s visual shape.
Why should you try different bin widths when making a histogram?
The default may not be appropriate, and comparing widths helps find a useful representation of the data. The tutorial used five-year age bins.
What did the overall passenger-age histogram reveal about the age distribution?
Many passengers were between 20 and 40, there were relatively few children, and the distribution had a long tail toward older ages, including passengers as old as 80.
What additional information did filling age-histogram bars by survival status provide?
It showed the relative numbers of passengers who survived and died within each age interval.
What survival pattern for young passengers appeared in the age histogram?
Several of the youngest age groups had more survivors than deaths, supporting the idea that children often had better survival outcomes.
What did the age histogram suggest about survival among older passengers?
Survival was generally low at older ages, although the chart included an older passenger who survived.
How is age compared between passengers who died and those who survived in a box-and-whisker plot?
Map survival status to the x-axis and age to the y-axis; the resulting boxes summarize age distributions for the two groups.
What age comparison did the box-and-whisker plot suggest?
Passengers who survived tended to be somewhat younger, but the difference was modest; the plot alone did not clearly show the distinct outcomes for children.
How is a density plot related to a histogram?
It presents a smoothed version of the distribution; it conveys similar information without the histogram’s squared-off bars.
What does the
alphasetting do in a ggplot2 density plot?It controls transparency. Partial transparency lets overlapping filled areas remain visible.
What additional variables were used to facet the age-and-survival analysis?
Sex and ticket class, creating panels that compare age distributions and survival across both categories.
Why is it useful to compare multiple visualizations of the same data?
Different plots reveal different aspects of a pattern; using several can provide a more complete understanding than relying on one alone.

Ask anything
We've read this whole study set, so questions about it get the best answers.