Introduction to R
- 120Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
Why is R considered an important language for data science?
R is widely used for data mining and data science, alongside Python, and is especially designed for statistical computing and data analysis.
Or swipe the card
120 cards
Why is R considered an important language for data science?
R is widely used for data mining and data science, alongside Python, and is especially designed for statistical computing and data analysis.
What are two major advantages of R's licensing model?
R is free and open source.
What does it mean that R is optimized for vector operations?
R can operate on entire vectors, rows, or tables without requiring explicit
forloops for every element.What role does the R community play in the language's usefulness?
The community provides support, examples, documentation, and continuing developments.
What are contributed or third-party R packages?
They are externally developed bundles of code that add functions and capabilities to R.
Where can R packages commonly be obtained?
Common sources include CRAN, CRANtastic, and GitHub.
What is CRAN?
CRAN is the Comprehensive R Archive Network, an official repository for R software and packages.
What are task views on CRAN used for?
They organize packages by subject area, such as Bayesian inference or computational physics.
What are some commonly used R packages and their purposes?
dplyrmanipulates data frames;tidyrcleans data;stringrhandles text;lubridatehandles dates;httrworks with web data;ggplot2creates graphics;shinycreates interactive applications;rioimports and exports data;rmarkdowncreates rich documents.What is
pacmanused for?pacmanis a package manager that can install, load, and unload R packages.How do you install R from the official project website?
Go to
r-project.org, choose the download link, select a mirror orcloudoption, choose the operating system, and follow the installation instructions.How is R installed on a Mac?
From CRAN, download the Mac package file and follow the standard installation directions.
How is R installed on Windows?
From CRAN, choose the Windows base installer, download it, and follow the standard installation procedure.
What is RStudio?
RStudio is an additional development environment that makes working with R easier and more organized.
What are two organizational advantages of RStudio?
It provides consistent keyboard commands across operating systems and combines R's tools in one interface.
What are the main panes in the RStudio interface?
The source or script pane, console, environment pane, and a pane for plots and other information.
What is an R script file?
It is a file containing R source code, commonly identified by the
.Rextension.What does a line beginning with
#mean in R?It is a comment and is not executed as code.
How can a line of code be run from an RStudio script?
Place the cursor on the line and press Command-Enter on Mac or Control-Enter on Windows/Linux.
What does the
head()function display?The first six rows of a data object by default.
What does the
summary()function provide for a categorical variable?Counts or frequencies for each category.
What does
summary()provide for a quantitative variable?The minimum, first quartile, median, mean, third quartile, and maximum.
What happens when
summary()is applied to an entire data frame?It provides numerical summaries for quantitative columns and frequency counts for categorical columns.
What does the
describe()function add beyondsummary()?It can provide sample size, mean, standard deviation, median, trimmed mean, median absolute deviation, minimum, maximum, range, skewness, kurtosis, and standard error.
Can
describe()be used appropriately on categorical variables?No. It is intended for quantitative variables; categorical output should be ignored.
What is the recommended order for using graphical and numerical summaries?
Examine pictures or visualizations first, then obtain numerical summaries.
What is the Iris data set used to demonstrate?
Measurements of sepal length, sepal width, petal length, and petal width for three Iris species.
What is the default
plot()command designed to do?It automatically chooses a suitable basic plot based on the number and types of variables supplied.
What plot does
plot(Iris$Species)produce?A bar chart showing the frequency of each of the three Iris species.
What plot does
plot(Iris$Species, Iris$Petal.Length)typically produce?A box plot comparing petal-length distributions across the three species.
What does a scatterplot of Iris petal length and petal width show?
A strong positive association: flowers with longer petals generally also have wider petals.
What happens when
plot()is applied to the entire Iris data frame?R produces a matrix of scatterplots for quantitative variables and displays category-related information for the species variable.
What are common graphical arguments for customizing an R plot?
colchanges color,pchchanges point character,mainadds a title,xlablabels the x-axis,ylablabels the y-axis, andlwdchanges line width.What does
pch = 19specify?Solid circular plotting points.
How can
plot()be used for mathematical functions?A function can be supplied with an interval, such as plotting cosine from 0 to 2π.
What is a bar chart best suited for?
Categorical data, especially frequencies or counts of categories.
Why does
barplot(Mtcars$cyl)not produce the desired frequency bar chart?It treats each row as an individual value instead of first counting how many observations belong to each cylinder category.
How can a frequency bar chart be created from raw categorical data?
First create a frequency table with
table(), then pass that table tobarplot().What is a histogram used for?
It displays the distribution of a quantitative or scaled variable.
What features should be examined in a histogram?
Shape, symmetry, skewness, modality, gaps, and outliers.
What does the y-axis of a default histogram generally represent?
The frequency or count of observations within each bin.
What does the
breaksargument control in a histogram?It suggests how many bins or bars the histogram should use.
What does
par(mfrow = c(3, 1))do?It arranges three plots in one column and three rows.
What are small multiples?
Multiple versions of the same chart displayed on the same scale for easy comparison across groups.
What pattern appears in Iris petal-length and petal-width histograms?
A low-end cluster is separated by a gap from a second, roughly bell-shaped distribution.
What should be done after changing graphical parameters with
par()?Restore the parameters to their previous settings, such as returning to one row and one column.
What is a scatterplot primarily used to visualize?
The association between two quantitative variables.
What should be assessed about linearity in a scatterplot?
Whether the association can reasonably be described by a straight line.
What is heteroscedasticity?
Unequal spread of observations across the range of the predictor variable.
Why are outliers important in scatterplots?
An unusual value or combination of values can strongly distort interpretations and statistical results.
What relationship appears between car weight and miles per gallon in
mtcars?A strong negative association: heavier cars generally have lower fuel efficiency.
What is plot overlaying?
Superimposing one plot directly on top of another.
What is the main benefit of overlaying plots?
It can provide more information and insight in the same amount of space.
What is the main risk of overly dense graphics?
They can become overwhelming and difficult to interpret.
What does a normal-density curve overlay help assess?
How closely the observed data resemble a normal distribution with a specified mean and standard deviation.
What is a kernel density estimator?
A smooth, nonparametric estimate of the distribution that follows the observed data more flexibly than a normal curve.
What does the
adjustparameter do for a kernel density estimate?It changes the amount of smoothing; larger values produce a smoother, slower-changing curve.
What is a rug plot?
A series of small vertical marks showing the location of individual observations along an axis.
What are the main R data types described in the content?
Numeric, character, logical, complex, and raw.
What is a vector in R?
A one-dimensional collection of values that all have the same data type.
How does R treat a single numeric value?
It treats it as a vector of length one rather than as a separate scalar type.
What is a matrix in R?
A two-dimensional structure with rows and columns in which all values have the same data type.
What is an array in R?
A structure like a matrix but with three or more dimensions.
What is a data frame?
A two-dimensional structure whose columns can contain different data types but must have the same length.
What is a list in R?
An ordered collection whose elements can have different classes, lengths, and structures.
What is coercion in R?
Changing an object from one data type or structure to another.
What is automatic coercion?
R's automatic conversion of mixed values to a common, less restrictive type.
What does
as.integer()do?It converts a compatible value to integer representation.
What does
as.numeric()do?It converts compatible character values, such as quoted numbers, into numeric values.
What does
as.data.frame()do?It converts a compatible object, such as a matrix, into a data frame.
What is a factor?
An attribute of a vector that specifies possible categorical values and their levels or order.
How are factor levels represented internally?
They are stored as numerical codes associated with category labels.
How can a vector be converted to a factor?
Use
as.factor().How can labels be assigned to factor levels?
Specify the levels and provide labels in the corresponding order.
How can factor levels be placed in a meaningful order?
List the levels in the desired order and assign matching labels.
What is R's assignment operator?
<-, read as “gets.”What does the colon operator do?
It generates sequential values between two endpoints, such as 0:10 or 10:0.
What does
seq()provide beyond the colon operator?It generates sequences with more control over the start, end, and step size.
What does
c()do in R?It concatenates, combines, or collects values into a vector.
What does
scan()do?It allows values to be entered interactively in the console.
What does
rep()do?It replicates values a specified number of times.
What is the difference between repeating a vector normally and using
eachinrep()?Normal repetition repeats the entire sequence in order;
eachrepeats each element the specified number of times before moving to the next.What are common data-file formats imported into R?
CSV, plain text, Excel
.xlsor.xlsx, and JSON.What is a CSV file?
A plain-text file in which values are separated by commas.
What is
rio?An R package that provides a consistent interface for importing and exporting many data formats.
What function does
riouse to import files?The
import()function.Why is importing Excel files directly sometimes discouraged?
Exporting the spreadsheet to a tab-delimited or comma-separated format is often more reliable and easier to import.
What does
View()do in RStudio?It opens a data object in a spreadsheet-like viewer.
How does
read.table()differ fromread.csv()?read.table()requires the delimiter to be specified when it is not the default, whereasread.csv()assumes comma separation.What is hierarchical clustering?
A method for grouping observations according to their similarity or distance from one another.
What is Euclidean distance used for in clustering?
It measures the distance between observations in multidimensional space.
What is the difference between divisive and agglomerative clustering?
Divisive clustering starts with all observations together and splits them; agglomerative clustering starts with separate observations and merges them.
What is a dendrogram?
A branching tree-like diagram that displays hierarchical clustering results.
What important limitation applies to a clustering solution?
It is valid only for the observations and variables used to create it.
What is principal component analysis, or PCA?
A dimensionality-reduction method that transforms many correlated variables into a smaller set of components.
What is the basic geometric idea behind PCA?
Project multidimensional observations onto new axes that capture important variation, reducing the number of dimensions.
What do centering and scaling do in PCA?
Centering makes variable means zero; scaling places variables on a comparable scale, commonly with unit variance.
How many principal components can PCA produce?
At most as many components as the original variables.
What does a scree plot show in PCA?
The amount of variation or component importance associated with each principal component.
What does the rotation matrix in PCA describe?
The association or loading of each original variable on each principal component.
What is a PCA biplot?
A two-dimensional plot showing observations and the directions or contributions of variables on selected components.
How does PCA differ from hierarchical clustering?
Hierarchical clustering groups cases, whereas PCA summarizes relationships among variables using new dimensions.
What is regression?
A method that uses one or more predictor variables to predict a particular outcome variable.
What does simultaneous-entry regression do?
It enters all predictor variables into the model at the same time.
What does
lm()stand for?Linear model.
In an R formula, what does
y ~ xmean?The outcome
yis modeled as predicted by, or as a function of,x.What does a regression coefficient represent?
The expected change in the outcome associated with a one-unit change in a predictor while the other predictors are held in the model.
What information is provided by a regression summary?
Coefficients, standard errors, t tests, p-values, significance indicators, and overall fit statistics such as multiple R2.
What does a p-value below the conventional .05 cutoff indicate in the regression output?
The coefficient is marked as statistically significant according to that cutoff.
What does multiple R2 measure in regression?
How well the predictors collectively explain or predict variation in the outcome.
What does an ANOVA table provide for a regression model?
A summary of model and residual variation used to evaluate the regression overall.
What do regression confidence intervals describe?
A range of plausible values for each regression coefficient, commonly reported as a 95% interval.
What are regression residuals?
The differences between observed outcome values and values predicted by the model.
What is the lasso?
The least absolute shrinkage and selection operator, a regression method that shrinks coefficients and can select predictors.
How do stepwise, stagewise, least-angle, and lasso regression relate to ordinary regression?
They are alternative regression procedures with different approaches to selecting or weighting predictors.
What is Python's relationship to R in the content?
Python is another major language for data science, and many tasks performed in R can also be performed in Python.
What is data visualization?
The practice of representing data graphically to reveal patterns, relationships, and distributions.
What is machine learning?
A set of methods for processing large amounts of data and generating predictions that can be applied to other data.
What are R user groups, or RUGs?
Local groups of people who use R and share knowledge or support.
What is useR!?
An annual conference for users of R.

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