1. Home
  2. Explore
  3. Computer Science
  4. Introduction to R

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Introduction to R

  • 120Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: R Foundations
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

Why is R considered an important language for data science?

Tap to flipClick to flipspace

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

  1. 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.

  2. What are two major advantages of R's licensing model?

    R is free and open source.

  3. What does it mean that R is optimized for vector operations?

    R can operate on entire vectors, rows, or tables without requiring explicit for loops for every element.

  4. What role does the R community play in the language's usefulness?

    The community provides support, examples, documentation, and continuing developments.

  5. What are contributed or third-party R packages?

    They are externally developed bundles of code that add functions and capabilities to R.

  6. Where can R packages commonly be obtained?

    Common sources include CRAN, CRANtastic, and GitHub.

  7. What is CRAN?

    CRAN is the Comprehensive R Archive Network, an official repository for R software and packages.

  8. What are task views on CRAN used for?

    They organize packages by subject area, such as Bayesian inference or computational physics.

  9. What are some commonly used R packages and their purposes?

    dplyr manipulates data frames; tidyr cleans data; stringr handles text; lubridate handles dates; httr works with web data; ggplot2 creates graphics; shiny creates interactive applications; rio imports and exports data; rmarkdown creates rich documents.

  10. What is pacman used for?

    pacman is a package manager that can install, load, and unload R packages.

  11. How do you install R from the official project website?

    Go to r-project.org, choose the download link, select a mirror or cloud option, choose the operating system, and follow the installation instructions.

  12. How is R installed on a Mac?

    From CRAN, download the Mac package file and follow the standard installation directions.

  13. How is R installed on Windows?

    From CRAN, choose the Windows base installer, download it, and follow the standard installation procedure.

  14. What is RStudio?

    RStudio is an additional development environment that makes working with R easier and more organized.

  15. What are two organizational advantages of RStudio?

    It provides consistent keyboard commands across operating systems and combines R's tools in one interface.

  16. 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.

  17. What is an R script file?

    It is a file containing R source code, commonly identified by the .R extension.

  18. What does a line beginning with # mean in R?

    It is a comment and is not executed as code.

  19. 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.

  20. What does the head() function display?

    The first six rows of a data object by default.

  21. What does the summary() function provide for a categorical variable?

    Counts or frequencies for each category.

  22. What does summary() provide for a quantitative variable?

    The minimum, first quartile, median, mean, third quartile, and maximum.

  23. What happens when summary() is applied to an entire data frame?

    It provides numerical summaries for quantitative columns and frequency counts for categorical columns.

  24. What does the describe() function add beyond summary()?

    It can provide sample size, mean, standard deviation, median, trimmed mean, median absolute deviation, minimum, maximum, range, skewness, kurtosis, and standard error.

  25. Can describe() be used appropriately on categorical variables?

    No. It is intended for quantitative variables; categorical output should be ignored.

  26. What is the recommended order for using graphical and numerical summaries?

    Examine pictures or visualizations first, then obtain numerical summaries.

  27. What is the Iris data set used to demonstrate?

    Measurements of sepal length, sepal width, petal length, and petal width for three Iris species.

  28. 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.

  29. What plot does plot(Iris$Species) produce?

    A bar chart showing the frequency of each of the three Iris species.

  30. What plot does plot(Iris$Species, Iris$Petal.Length) typically produce?

    A box plot comparing petal-length distributions across the three species.

  31. 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.

  32. 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.

  33. What are common graphical arguments for customizing an R plot?

    col changes color, pch changes point character, main adds a title, xlab labels the x-axis, ylab labels the y-axis, and lwd changes line width.

  34. What does pch = 19 specify?

    Solid circular plotting points.

  35. How can plot() be used for mathematical functions?

    A function can be supplied with an interval, such as plotting cosine from 000 to 2π2\pi2π.

  36. What is a bar chart best suited for?

    Categorical data, especially frequencies or counts of categories.

  37. 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.

  38. How can a frequency bar chart be created from raw categorical data?

    First create a frequency table with table(), then pass that table to barplot().

  39. What is a histogram used for?

    It displays the distribution of a quantitative or scaled variable.

  40. What features should be examined in a histogram?

    Shape, symmetry, skewness, modality, gaps, and outliers.

  41. What does the y-axis of a default histogram generally represent?

    The frequency or count of observations within each bin.

  42. What does the breaks argument control in a histogram?

    It suggests how many bins or bars the histogram should use.

  43. What does par(mfrow = c(3, 1)) do?

    It arranges three plots in one column and three rows.

  44. What are small multiples?

    Multiple versions of the same chart displayed on the same scale for easy comparison across groups.

  45. 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.

  46. 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.

  47. What is a scatterplot primarily used to visualize?

    The association between two quantitative variables.

  48. What should be assessed about linearity in a scatterplot?

    Whether the association can reasonably be described by a straight line.

  49. What is heteroscedasticity?

    Unequal spread of observations across the range of the predictor variable.

  50. Why are outliers important in scatterplots?

    An unusual value or combination of values can strongly distort interpretations and statistical results.

  51. What relationship appears between car weight and miles per gallon in mtcars?

    A strong negative association: heavier cars generally have lower fuel efficiency.

  52. What is plot overlaying?

    Superimposing one plot directly on top of another.

  53. What is the main benefit of overlaying plots?

    It can provide more information and insight in the same amount of space.

  54. What is the main risk of overly dense graphics?

    They can become overwhelming and difficult to interpret.

  55. 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.

  56. What is a kernel density estimator?

    A smooth, nonparametric estimate of the distribution that follows the observed data more flexibly than a normal curve.

  57. What does the adjust parameter do for a kernel density estimate?

    It changes the amount of smoothing; larger values produce a smoother, slower-changing curve.

  58. What is a rug plot?

    A series of small vertical marks showing the location of individual observations along an axis.

  59. What are the main R data types described in the content?

    Numeric, character, logical, complex, and raw.

  60. What is a vector in R?

    A one-dimensional collection of values that all have the same data type.

  61. How does R treat a single numeric value?

    It treats it as a vector of length one rather than as a separate scalar type.

  62. What is a matrix in R?

    A two-dimensional structure with rows and columns in which all values have the same data type.

  63. What is an array in R?

    A structure like a matrix but with three or more dimensions.

  64. What is a data frame?

    A two-dimensional structure whose columns can contain different data types but must have the same length.

  65. What is a list in R?

    An ordered collection whose elements can have different classes, lengths, and structures.

  66. What is coercion in R?

    Changing an object from one data type or structure to another.

  67. What is automatic coercion?

    R's automatic conversion of mixed values to a common, less restrictive type.

  68. What does as.integer() do?

    It converts a compatible value to integer representation.

  69. What does as.numeric() do?

    It converts compatible character values, such as quoted numbers, into numeric values.

  70. What does as.data.frame() do?

    It converts a compatible object, such as a matrix, into a data frame.

  71. What is a factor?

    An attribute of a vector that specifies possible categorical values and their levels or order.

  72. How are factor levels represented internally?

    They are stored as numerical codes associated with category labels.

  73. How can a vector be converted to a factor?

    Use as.factor().

  74. How can labels be assigned to factor levels?

    Specify the levels and provide labels in the corresponding order.

  75. How can factor levels be placed in a meaningful order?

    List the levels in the desired order and assign matching labels.

  76. What is R's assignment operator?

    <-, read as “gets.”

  77. What does the colon operator do?

    It generates sequential values between two endpoints, such as 0:100:100:10 or 10:010:010:0.

  78. What does seq() provide beyond the colon operator?

    It generates sequences with more control over the start, end, and step size.

  79. What does c() do in R?

    It concatenates, combines, or collects values into a vector.

  80. What does scan() do?

    It allows values to be entered interactively in the console.

  81. What does rep() do?

    It replicates values a specified number of times.

  82. What is the difference between repeating a vector normally and using each in rep()?

    Normal repetition repeats the entire sequence in order; each repeats each element the specified number of times before moving to the next.

  83. What are common data-file formats imported into R?

    CSV, plain text, Excel .xls or .xlsx, and JSON.

  84. What is a CSV file?

    A plain-text file in which values are separated by commas.

  85. What is rio?

    An R package that provides a consistent interface for importing and exporting many data formats.

  86. What function does rio use to import files?

    The import() function.

  87. 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.

  88. What does View() do in RStudio?

    It opens a data object in a spreadsheet-like viewer.

  89. How does read.table() differ from read.csv()?

    read.table() requires the delimiter to be specified when it is not the default, whereas read.csv() assumes comma separation.

  90. What is hierarchical clustering?

    A method for grouping observations according to their similarity or distance from one another.

  91. What is Euclidean distance used for in clustering?

    It measures the distance between observations in multidimensional space.

  92. 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.

  93. What is a dendrogram?

    A branching tree-like diagram that displays hierarchical clustering results.

  94. What important limitation applies to a clustering solution?

    It is valid only for the observations and variables used to create it.

  95. What is principal component analysis, or PCA?

    A dimensionality-reduction method that transforms many correlated variables into a smaller set of components.

  96. What is the basic geometric idea behind PCA?

    Project multidimensional observations onto new axes that capture important variation, reducing the number of dimensions.

  97. What do centering and scaling do in PCA?

    Centering makes variable means zero; scaling places variables on a comparable scale, commonly with unit variance.

  98. How many principal components can PCA produce?

    At most as many components as the original variables.

  99. What does a scree plot show in PCA?

    The amount of variation or component importance associated with each principal component.

  100. What does the rotation matrix in PCA describe?

    The association or loading of each original variable on each principal component.

  101. What is a PCA biplot?

    A two-dimensional plot showing observations and the directions or contributions of variables on selected components.

  102. How does PCA differ from hierarchical clustering?

    Hierarchical clustering groups cases, whereas PCA summarizes relationships among variables using new dimensions.

  103. What is regression?

    A method that uses one or more predictor variables to predict a particular outcome variable.

  104. What does simultaneous-entry regression do?

    It enters all predictor variables into the model at the same time.

  105. What does lm() stand for?

    Linear model.

  106. In an R formula, what does y ~ x mean?

    The outcome y is modeled as predicted by, or as a function of, x.

  107. 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.

  108. What information is provided by a regression summary?

    Coefficients, standard errors, t tests, p-values, significance indicators, and overall fit statistics such as multiple R2R^2R2.

  109. 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.

  110. What does multiple R2R^2R2 measure in regression?

    How well the predictors collectively explain or predict variation in the outcome.

  111. What does an ANOVA table provide for a regression model?

    A summary of model and residual variation used to evaluate the regression overall.

  112. What do regression confidence intervals describe?

    A range of plausible values for each regression coefficient, commonly reported as a 95% interval.

  113. What are regression residuals?

    The differences between observed outcome values and values predicted by the model.

  114. What is the lasso?

    The least absolute shrinkage and selection operator, a regression method that shrinks coefficients and can select predictors.

  115. 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.

  116. 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.

  117. What is data visualization?

    The practice of representing data graphically to reveal patterns, relationships, and distributions.

  118. What is machine learning?

    A set of methods for processing large amounts of data and generating predictions that can be applied to other data.

  119. What are R user groups, or RUGs?

    Local groups of people who use R and share knowledge or support.

  120. What is useR!?

    An annual conference for users of R.

Card 1 of 120
Card 1 of 120

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent