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

  • 89Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: R Foundations

Why is R especially important for data science according to the content?

89 questions

  1. 1

    Why is R especially important for data science according to the content?

    1. A

      It is designed mainly for word processing and document formatting

    2. B

      It replaces every other programming language used in data science

    3. C

      It is free, open source, vectorized, and supported by many packages

    4. D

      It is proprietary, expensive, and limited to spreadsheet calculations

    Correct answer
    C

    It is free, open source, vectorized, and supported by many packages

    Explanation

    R is emphasized because it is free and open source, supports vector operations, has a strong community, and offers thousands of contributed packages.

  2. 2

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

    1. A

      R can only store numerical data in one-dimensional vectors

    2. B

      Operations must always be written as repeated for loops

    3. C

      Operations can often be applied to whole vectors without explicit loops

    4. D

      R automatically converts every data set into a graphic

    Correct answer
    C

    Operations can often be applied to whole vectors without explicit loops

    Explanation

    Vectorization allows an operation to be applied to an entire row, column, or vector without explicitly writing a loop for every element.

  3. 3

    What is the main purpose of R packages?

    1. A

      They store only comments that explain how R commands work

    2. B

      They replace the R language with a separate operating system

    3. C

      They prevent users from installing third-party software

    4. D

      They add bundles of code and functions that extend R's capabilities

    Correct answer
    D

    They add bundles of code and functions that extend R's capabilities

    Explanation

    Packages are bundles of code that add functions and capabilities to R.

  4. 4

    Where should a user begin when installing R?

    1. A

      At a spreadsheet website that converts files into scripts

    2. B

      At the R Project website for statistical computing

    3. C

      At the RStudio website without installing R first

    4. D

      At GitHub exclusively, regardless of the operating system

    Correct answer
    B

    At the R Project website for statistical computing

    Explanation

    R is downloaded from the R Project website, where the user selects the download link and then an appropriate mirror or CRAN location.

  5. 5

    Why is the cloud mirror a convenient choice when downloading R?

    1. A

      It eliminates the need to select an operating system

    2. B

      It installs RStudio and all contributed packages automatically

    3. C

      It automatically directs the user to a suitable mirror

    4. D

      It converts R scripts into spreadsheet files during installation

    Correct answer
    C

    It automatically directs the user to a suitable mirror

    Explanation

    The cloud mirror automatically directs the user to whichever listed mirror is best for the user's location.

  6. 6

    What does an R file with the extension .R generally contain?

    1. A

      A compressed operating-system installer

    2. B

      R source code or script commands

    3. C

      A spreadsheet with multiple worksheets

    4. D

      A browser-based package documentation file

    Correct answer
    B

    R source code or script commands

    Explanation

    The .R extension identifies an R source or script file.

  7. 7

    What does a line beginning with a pound sign or hashtag represent in an R script?

    1. A

      A command that immediately plots the data

    2. B

      A required package-installation instruction

    3. C

      A command that clears the R console

    4. D

      A comment that is not executed as code

    Correct answer
    D

    A comment that is not executed as code

    Explanation

    Lines beginning with the pound sign are comments and are not run as executable code.

  8. 8

    What is the purpose of the RStudio application?

    1. A

      It converts every R analysis into a presentation automatically

    2. B

      It is used only to download operating-system updates

    3. C

      It provides a more organized and convenient interface for working with R

    4. D

      It is a replacement for the R language and its interpreter

    Correct answer
    C

    It provides a more organized and convenient interface for working with R

    Explanation

    RStudio sits on top of R and provides a unified, flexible environment for writing code, viewing output, managing variables, and viewing plots.

  9. 9

    Which arrangement best describes the default RStudio interface?

    1. A

      Script at the top, console below, environment and plots on the right

    2. B

      Plots at the top, packages below, and scripts hidden in a browser

    3. C

      Environment on the left, script in a separate application, and console absent

    4. D

      Console at the top, script below, and no area for plots

    Correct answer
    A

    Script at the top, console below, environment and plots on the right

    Explanation

    RStudio commonly places the source window at the top, the console below it, and the environment and plots in panes on the right.

  10. 10

    What is one advantage RStudio provides across operating systems?

    1. A

      It allows only Windows users to access the console

    2. B

      It prevents R from running on different operating systems

    3. C

      It changes all R commands into spreadsheet formulas

    4. D

      It provides more consistent commands on Mac, Windows, and Linux

    Correct answer
    D

    It provides more consistent commands on Mac, Windows, and Linux

    Explanation

    RStudio helps standardize keyboard commands and interaction across Mac, Windows, and Linux.

  11. 11

    Which statement correctly distinguishes installing a package from loading it?

    1. A

      Installing uses its functions immediately; loading permanently deletes its files

    2. B

      Installing creates a data frame; loading converts it into a matrix

    3. C

      Installing and loading are identical operations with no functional difference

    4. D

      Installing stores it on the computer; loading makes it available to current code

    Correct answer
    D

    Installing stores it on the computer; loading makes it available to current code

    Explanation

    Installation makes a package available on the hard drive, while loading makes its functions accessible during the current R session.

  12. 12

    Which source is the official repository with package documentation?

    1. A

      The RStudio console, which stores every package permanently

    2. B

      CRANtastic, which only lists links without official hosting

    3. C

      GitHub Trending, which is unrelated to R packages

    4. D

      CRAN, the Comprehensive R Archive Network

    Correct answer
    D

    CRAN, the Comprehensive R Archive Network

    Explanation

    CRAN is the official R package repository and includes package documentation.

  13. 13

    What is the purpose of CRAN task views?

    1. A

      They convert package code into graphical output

    2. B

      They organize packages by subject area or topic

    3. C

      They show only the packages installed in the current session

    4. D

      They rank operating systems by installation difficulty

    Correct answer
    B

    They organize packages by subject area or topic

    Explanation

    Task views group CRAN packages by topics such as Bayesian inference, chemometrics, and computational physics.

  14. 14

    What kind of information does CRANtastic emphasize?

    1. A

      Operating-system-specific R installation errors

    2. B

      Only the base packages installed with R

    3. C

      Recently updated and popular R packages

    4. D

      The numerical results of a user's regression models

    Correct answer
    C

    Recently updated and popular R packages

    Explanation

    CRANtastic lists popular and recently updated packages, although its links redirect users to CRAN for downloading.

  15. 15

    Which package is primarily used for manipulating data frames?

    1. A

      lubridate

    2. B

      dplyr

    3. C

      stringr

    4. D

      ggplot2

    Correct answer
    B

    dplyr

    Explanation

    dplyr is identified as a package for manipulating data frames.

  16. 16

    Which package is designed for working with strings or text?

    1. A

      httr

    2. B

      stringr

    3. C

      shiny

    4. D

      rio

    Correct answer
    B

    stringr

    Explanation

    stringr provides tools for working with strings and other text information.

  17. 17

    Which package is associated with creating interactive web applications?

    1. A

      shiny

    2. B

      lubridate

    3. C

      tidyr

    4. D

      readr

    Correct answer
    A

    shiny

    Explanation

    Shiny allows users to create interactive applications that can be deployed on websites.

  18. 18

    What is the main purpose of the Pacman package in the examples?

    1. A

      It creates only bar charts from categorical variables

    2. B

      It imports Excel files without using any other function

    3. C

      It replaces all statistical functions in base R

    4. D

      It simplifies installing, loading, and unloading packages

    Correct answer
    D

    It simplifies installing, loading, and unloading packages

    Explanation

    Pacman acts as a package manager and can make package installation and loading more convenient.

  19. 19

    What does the default plot command in R do particularly well?

    1. A

      It always produces the same bar chart regardless of the input

    2. B

      It adapts the graphic to the number and types of variables supplied

    3. C

      It can plot only mathematical functions and not data

    4. D

      It requires the user to specify the graph type every time

    Correct answer
    B

    It adapts the graphic to the number and types of variables supplied

    Explanation

    The default plot command adapts to both the number of variables and their data types.

  20. 20

    What does plotting a single categorical variable such as iris species produce by default?

    1. A

      A bar chart showing the count in each category

    2. B

      A regression line showing predicted category membership

    3. C

      A histogram showing the numerical distribution of scores

    4. D

      A scatterplot showing the relationship between two measurements

    Correct answer
    A

    A bar chart showing the count in each category

    Explanation

    A single categorical variable is displayed as a simple bar chart. In the iris data, each species has 50 observations.

  21. 21

    What does plotting one quantitative variable generally show?

    1. A

      Its values or distribution against the observation index

    2. B

      A regression coefficient for every observation

    3. C

      A bar for every category in a separate categorical variable

    4. D

      A matrix containing every possible pair of variables

    Correct answer
    A

    Its values or distribution against the observation index

    Explanation

    When one quantitative variable is plotted, R commonly places the observation index on the horizontal axis and the variable values on the vertical axis.

  22. 22

    What plot does R commonly choose for one categorical and one quantitative variable?

    1. A

      A correlation matrix

    2. B

      A box plot

    3. C

      A pie chart

    4. D

      A time-series line plot

    Correct answer
    B

    A box plot

    Explanation

    When the first variable is categorical and the second is quantitative, the default plot commonly becomes a box plot comparing groups.

  23. 23

    What does plotting two quantitative variables produce?

    1. A

      A bar chart showing category frequencies

    2. B

      A scatterplot showing their association

    3. C

      A box plot showing only the categorical levels

    4. D

      A histogram showing only the first variable

    Correct answer
    B

    A scatterplot showing their association

    Explanation

    Two quantitative variables are displayed in a scatterplot, allowing their relationship to be examined.

  24. 24

    What does plotting an entire data frame such as iris provide?

    1. A

      A list of package names required by the data frame

    2. B

      A single bar chart containing only the first column

    3. C

      A matrix of plots for quantitative variables and displays for categorical variables

    4. D

      A regression model using every column automatically

    Correct answer
    C

    A matrix of plots for quantitative variables and displays for categorical variables

    Explanation

    Plotting the entire iris data frame produces a matrix of scatterplots for quantitative variables and a categorical display for species.

  25. 25

    Which plot option changes the plotting symbol in base R?

    1. A

      xlab

    2. B

      lwd

    3. C

      main

    4. D

      pch

    Correct answer
    D

    pch

    Explanation

    The pch argument specifies the plotting character; the value 19 represents a solid circle.

  26. 26

    Which plot option changes the line width?

    1. A

      ylab

    2. B

      lwd

    3. C

      col

    4. D

      breaks

    Correct answer
    B

    lwd

    Explanation

    The lwd argument controls line width.

  27. 27

    What is a histogram primarily used to examine?

    1. A

      The names of categories in a factor

    2. B

      The coefficients of a regression equation

    3. C

      The hierarchy of clustered observations

    4. D

      The distribution of a quantitative variable

    Correct answer
    D

    The distribution of a quantitative variable

    Explanation

    Histograms are basic graphics for quantitative, scaled, interval, or ratio-level variables.

  28. 28

    Which feature would be especially important to investigate in a histogram?

    1. A

      The order in which packages were loaded

    2. B

      Shape, gaps, symmetry, and possible outliers

    3. C

      Only the spelling of the variable name

    4. D

      Only the operating system used to create the plot

    Correct answer
    B

    Shape, gaps, symmetry, and possible outliers

    Explanation

    Histograms help reveal distributional shape, gaps, symmetry, skewness, and unusual observations that may affect later analyses.

  29. 29

    What are small multiples?

    1. A

      Several versions of the same chart shown on a common scale

    2. B

      A method for reducing a data frame to one variable

    3. C

      A single chart containing only very small symbols

    4. D

      Several unrelated charts shown with different scales

    Correct answer
    A

    Several versions of the same chart shown on a common scale

    Explanation

    Small multiples display repeated charts for different groups or conditions using the same scale, making comparisons easier.

  30. 30

    What is the canonical use of a scatterplot?

    1. A

      Visualizing the association between two quantitative variables

    2. B

      Counting observations in a categorical variable

    3. C

      Showing the number of bins in a histogram

    4. D

      Displaying the levels and labels of a factor

    Correct answer
    A

    Visualizing the association between two quantitative variables

    Explanation

    Scatterplots are most commonly used to visualize relationships between two quantitative variables.

  31. 31

    What does heteroscedasticity mean in a scatterplot?

    1. A

      The spread of scores changes substantially across the range of the predictor

    2. B

      The variables contain only categorical values

    3. C

      The relationship between variables is perfectly linear

    4. D

      Every observation has exactly the same residual

    Correct answer
    A

    The spread of scores changes substantially across the range of the predictor

    Explanation

    Heteroscedasticity occurs when the spread of observations changes, often appearing as a fan shape, across the x-axis.

  32. 32

    Why should plots generally be examined before numerical analyses?

    1. A

      Plots convert categorical variables into quantitative measurements

    2. B

      Plots automatically prove that every statistical test is valid

    3. C

      Plots eliminate the need to calculate any descriptive statistics

    4. D

      Plots reveal patterns, gaps, outliers, and assumptions that numbers may hide

    Correct answer
    D

    Plots reveal patterns, gaps, outliers, and assumptions that numbers may hide

    Explanation

    Visualization provides an initial impression of the data and can guide later numerical or statistical analyses.

  33. 33

    Why might plots be overlaid?

    1. A

      To increase information density and provide complementary perspectives

    2. B

      To make every possible visual element compete for attention

    3. C

      To ensure that unrelated variables use identical interpretations

    4. D

      To replace all numerical summaries with decorative graphics

    Correct answer
    A

    To increase information density and provide complementary perspectives

    Explanation

    Overlaying plots can provide more information and insight in the same space, but the views should complement rather than compete with one another.

  34. 34

    What does a rug plot add to a histogram?

    1. A

      A categorical legend showing package names

    2. B

      A small mark for each individual observation along the axis

    3. C

      A second y-axis containing regression coefficients

    4. D

      A normal curve with automatically estimated parameters

    Correct answer
    B

    A small mark for each individual observation along the axis

    Explanation

    A rug plot places small vertical marks along the axis to show the location of individual data points.

  35. 35

    What information does the basic summary function provide for a categorical variable?

    1. A

      A standard deviation and standard error for each category

    2. B

      Counts or frequencies for the categories

    3. C

      A regression slope and confidence interval

    4. D

      A principal component loading for each category

    Correct answer
    B

    Counts or frequencies for the categories

    Explanation

    For a categorical variable such as iris species, summary reports the number of observations in each category.

  36. 36

    Which set of values is included in the basic summary of a quantitative variable?

    1. A

      Only the frequency and percentage of each category

    2. B

      Only the regression coefficient and its p-value

    3. C

      Only the package version and installation location

    4. D

      Minimum, quartiles, median, mean, and maximum

    Correct answer
    D

    Minimum, quartiles, median, mean, and maximum

    Explanation

    The basic summary for a quantitative variable includes the minimum, first quartile, median, mean, third quartile, and maximum.

  37. 37

    What additional information does the describe function provide?

    1. A

      Only the names of packages loaded into memory

    2. B

      Measures such as sample size, standard deviation, skewness, kurtosis, and standard error

    3. C

      Only category labels and their alphabetical order

    4. D

      Only the first six rows of a data frame

    Correct answer
    B

    Measures such as sample size, standard deviation, skewness, kurtosis, and standard error

    Explanation

    The describe function from the psych package supplies more detailed numerical summaries, including nnn, mean, standard deviation, skewness, kurtosis, and standard error.

  38. 38

    Which type of variable is describe intended primarily for?

    1. A

      Comments in an R script

    2. B

      Package names and file paths

    3. C

      Categorical variables only

    4. D

      Quantitative variables

    Correct answer
    D

    Quantitative variables

    Explanation

    The content specifically cautions that describe is intended for quantitative variables and should not be used to interpret categorical variables such as species.

  39. 39

    What is the recommended sequence for examining data?

    1. A

      Create graphical summaries first, then follow with numerical summaries

    2. B

      Run complex models first, then inspect the raw data if needed

    3. C

      Import the data and immediately delete all visual information

    4. D

      Calculate p-values first, then decide whether the variables exist

    Correct answer
    A

    Create graphical summaries first, then follow with numerical summaries

    Explanation

    The recommended approach is pictures first and numbers later, using visualizations to guide and complement precise numerical summaries.

  40. 40

    What is the purpose of selecting cases in R?

    1. A

      To reorder the columns without changing the observations

    2. B

      To install only the packages used by a data frame

    3. C

      To change every variable into a character variable

    4. D

      To focus an analysis on particular observations or subgroups

    Correct answer
    D

    To focus an analysis on particular observations or subgroups

    Explanation

    Case selection allows the analyst to examine particular observations or subgroups more closely.

  41. 41

    How can cases be selected using a categorical variable?

    1. A

      By selecting values that are numerically below a cutoff

    2. B

      By testing whether the variable equals a specified category

    3. C

      By changing the category into a matrix index only

    4. D

      By calculating the mean of the category labels

    Correct answer
    B

    By testing whether the variable equals a specified category

    Explanation

    Categorical selection uses a condition such as species equal to a particular quoted category.

  42. 42

    How can cases be selected using a quantitative variable?

    1. A

      By applying a numerical condition such as being below a cutoff

    2. B

      By selecting only the first row regardless of its value

    3. C

      By replacing the variable with a package name

    4. D

      By placing the category name in quotation marks

    Correct answer
    A

    By applying a numerical condition such as being below a cutoff

    Explanation

    Quantitative cases can be selected with conditions such as a measurement being less than a specified value.

  43. 43

    What does the ampersand represent when combining selection conditions in R?

    1. A

      Both conditions must be true

    2. B

      Either condition may be true

    3. C

      The condition should be converted into text

    4. D

      The selected rows should be deleted permanently

    Correct answer
    A

    Both conditions must be true

    Explanation

    The ampersand combines conditions so that observations must satisfy both selectors.

  44. 44

    Why create a new subset data frame instead of repeating a selection expression?

    1. A

      The original data frame is automatically converted into a package

    2. B

      The subset always contains every row and column from the original

    3. C

      The same subgroup can be reused conveniently in later analyses

    4. D

      The new data frame prevents all descriptive statistics from being calculated

    Correct answer
    C

    The same subgroup can be reused conveniently in later analyses

    Explanation

    Saving a frequently used selection as a new data frame makes repeated analyses of that subgroup easier.

  45. 45

    Which statement correctly distinguishes data types from data structures?

    1. A

      Types and structures are identical terms with no practical distinction

    2. B

      Types describe the nature of values; structures describe how values are arranged

    3. C

      Types describe file locations; structures describe package documentation

    4. D

      Types apply only to plots; structures apply only to regression models

    Correct answer
    B

    Types describe the nature of values; structures describe how values are arranged

    Explanation

    Data types include numeric, character, logical, complex, and raw values, while structures include vectors, matrices, arrays, data frames, and lists.

  46. 46

    Which data type represents true or false values in R?

    1. A

      Logical

    2. B

      Raw

    3. C

      Character

    4. D

      Double

    Correct answer
    A

    Logical

    Explanation

    Logical values represent TRUE and FALSE, including their abbreviated forms T and F.

  47. 47

    What is a vector in R?

    1. A

      A three-dimensional structure containing only character values

    2. B

      A one-dimensional collection whose elements share one data type

    3. C

      A two-dimensional collection whose columns may have different lengths

    4. D

      A nested collection in which every element must be a data frame

    Correct answer
    B

    A one-dimensional collection whose elements share one data type

    Explanation

    A vector is a one-dimensional collection, and all of its elements must have the same data type.

  48. 48

    How does R treat a single number in relation to vectors?

    1. A

      It treats the single number as a vector of length one

    2. B

      It treats the single number as a list containing three elements

    3. C

      It treats the single number as a matrix with one row and column

    4. D

      It refuses to store a single number without converting it to text

    Correct answer
    A

    It treats the single number as a vector of length one

    Explanation

    Although other contexts may call a single number a scalar, R treats it as a vector of length one.

  49. 49

    What distinguishes a matrix from a vector?

    1. A

      A matrix is always nested inside another matrix

    2. B

      A matrix cannot contain numerical values

    3. C

      A matrix has two dimensions represented by rows and columns

    4. D

      A matrix can contain values of any type in every individual cell

    Correct answer
    C

    A matrix has two dimensions represented by rows and columns

    Explanation

    A matrix is a two-dimensional structure with rows and columns, and all of its elements must have the same class.

  50. 50

    What is an array in R?

    1. A

      A one-dimensional vector that must contain text

    2. B

      A matrix-like structure with three or more dimensions

    3. C

      A list that can contain only logical values

    4. D

      A data frame whose columns have unequal lengths

    Correct answer
    B

    A matrix-like structure with three or more dimensions

    Explanation

    An array extends the matrix idea to three or more dimensions.

  51. 51

    Why is a data frame analogous to a spreadsheet?

    1. A

      It requires every cell to have exactly the same data type

    2. B

      It contains equal-length columns that may have different data types

    3. C

      It can contain nested objects of arbitrary lengths in every cell

    4. D

      It stores only one variable in a single row

    Correct answer
    B

    It contains equal-length columns that may have different data types

    Explanation

    A data frame is two-dimensional, its columns have equal lengths, and different columns may contain different types, much like a spreadsheet.

  52. 52

    What is the main characteristic of an R list?

    1. A

      It must have exactly two dimensions and named columns

    2. B

      It can contain only equal-length numerical vectors

    3. C

      It can contain elements of different classes, lengths, and structures

    4. D

      It automatically converts every element into a factor

    Correct answer
    C

    It can contain elements of different classes, lengths, and structures

    Explanation

    Lists are highly flexible ordered collections that can contain elements of different classes, lengths, structures, and even other lists.

  53. 53

    What is coercion?

    1. A

      Displaying a data frame as a plot without changing its contents

    2. B

      Sorting observations alphabetically without changing their type

    3. C

      Changing an object from one data type or structure to another

    4. D

      Deleting all missing values from a data set automatically

    Correct answer
    C

    Changing an object from one data type or structure to another

    Explanation

    Coercion changes the type or structure of a data object, such as converting a matrix to a data frame or character values to numeric values.

  54. 54

    What happens during automatic coercion when numeric, character, and logical values are combined?

    1. A

      They may all be converted to character values

    2. B

      They are automatically converted into a matrix of integers

    3. C

      They remain separate objects without any conversion

    4. D

      They are always converted to logical values

    Correct answer
    A

    They may all be converted to character values

    Explanation

    R may coerce mixed values to the least restrictive, most general type; character is more general than numeric or logical in this situation.

  55. 55

    What does a factor represent in R?

    1. A

      A package object that stores regression coefficients

    2. B

      A numerical variable whose values must be normally distributed

    3. C

      A vector attribute specifying possible categorical values and their order

    4. D

      A matrix attribute specifying the number of rows and columns

    Correct answer
    C

    A vector attribute specifying possible categorical values and their order

    Explanation

    A factor represents categorical information, including its possible levels and, when appropriate, their order.

  56. 56

    Why can a factor display text labels while retaining numerical codes internally?

    1. A

      Factors convert all labels into independent regression models

    2. B

      Factors store only text and calculate numerical codes when printed

    3. C

      Factors store category codes internally and associate them with labels

    4. D

      Factors remove the original ordering of the categories

    Correct answer
    C

    Factors store category codes internally and associate them with labels

    Explanation

    A factor can retain numerical codes such as 1, 2, and 3 internally while displaying labels such as Mac OS, Windows, and Linux.

  57. 57

    What is required when assigning labels to factor levels?

    1. A

      The labels must all be numerical rather than textual

    2. B

      The labels must contain more levels than the original variable

    3. C

      The labels must always be entered in alphabetical order

    4. D

      The labels must correspond to the intended order of the levels

    Correct answer
    D

    The labels must correspond to the intended order of the levels

    Explanation

    Labels are matched to factor levels in the order supplied, so the intended order must be specified carefully.

  58. 58

    What does the assignment operator in R do?

    1. A

      It compares two values for equality

    2. B

      It selects only categorical rows from a data frame

    3. C

      It assigns a value or expression to an object

    4. D

      It loads a package from CRAN

    Correct answer
    C

    It assigns a value or expression to an object

    Explanation

    The left-arrow assignment operator assigns the result of an expression to an object.

  59. 59

    What sequence does the colon operator generate in R?

    1. A

      A table of frequencies for every category

    2. B

      A list containing values of unrelated data types

    3. C

      A random sample of values from two endpoints

    4. D

      A sequence of values between two endpoints in regular order

    Correct answer
    D

    A sequence of values between two endpoints in regular order

    Explanation

    The colon operator generates sequential values, such as the values from 0 through 10 or from 10 down to 0.

  60. 60

    What additional control does the sequence function provide compared with the colon operator?

    1. A

      It converts all values into categorical labels automatically

    2. B

      It creates a plot without requiring any values

    3. C

      It allows the user to specify details such as the step size

    4. D

      It imports data from Excel without a file path

    Correct answer
    C

    It allows the user to specify details such as the step size

    Explanation

    The sequence function can specify how values progress, such as counting downward by three.

  61. 61

    What does the concatenate function do?

    1. A

      It converts a data frame into a regression model

    2. B

      It calculates a histogram for a quantitative variable

    3. C

      It loads every package currently installed

    4. D

      It combines specified values into a vector

    Correct answer
    D

    It combines specified values into a vector

    Explanation

    The concatenate function, written as c, combines values into a collection such as a vector.

  62. 62

    What is the purpose of the scan function?

    1. A

      It scans a data frame for statistically significant coefficients

    2. B

      It converts character values into factor labels

    3. C

      It creates a sequence using a specified step size

    4. D

      It allows values to be entered interactively from the console

    Correct answer
    D

    It allows values to be entered interactively from the console

    Explanation

    scan reads values entered interactively, ending input when the user submits a blank line.

  63. 63

    What does the rep function do?

    1. A

      It changes a matrix into an array

    2. B

      It removes all repeated values from a data frame

    3. C

      It calculates the residuals from a regression model

    4. D

      It repeats values or groups of values

    Correct answer
    D

    It repeats values or groups of values

    Explanation

    rep replicates values, either by repeating a whole set in sequence or by repeating each value separately.

  64. 64

    What does CSV stand for?

    1. A

      Computed sequence vector

    2. B

      Comma-separated values

    3. C

      Categorical statistical variables

    4. D

      Compressed spreadsheet version

    Correct answer
    B

    Comma-separated values

    Explanation

    CSV files store tabular data as comma-separated values and are widely supported by spreadsheet and statistical programs.

  65. 65

    Which format is specifically associated with JavaScript Object Notation?

    1. A

      TXT

    2. B

      CSV

    3. C

      XLS

    4. D

      JSON

    Correct answer
    D

    JSON

    Explanation

    JSON stands for JavaScript Object Notation and is commonly encountered in web data.

  66. 66

    What is the main advantage of the rio package for importing data?

    1. A

      It requires a different syntax for every operating system

    2. B

      It provides one consistent import function for multiple file formats

    3. C

      It replaces every data frame with a nested list

    4. D

      It imports only CSV files but automatically performs regression

    Correct answer
    B

    It provides one consistent import function for multiple file formats

    Explanation

    rio simplifies importing by using a consistent import function that can recognize several common file formats.

  67. 67

    Why is exporting an Excel spreadsheet as CSV often recommended?

    1. A

      CSV preserves every Excel formatting feature more completely

    2. B

      CSV eliminates the need to identify the file location

    3. C

      CSV automatically converts all categorical variables into factors

    4. D

      CSV is simpler and can be imported reliably by many programs

    Correct answer
    D

    CSV is simpler and can be imported reliably by many programs

    Explanation

    The R documentation recommends exporting Excel data to tab-delimited or comma-separated text when possible because these formats are easier to import reliably.

  68. 68

    Why might read.table require an explicit separator when importing a tab-delimited file?

    1. A

      The function cannot read files containing column names

    2. B

      The function automatically treats every tab as a missing value

    3. C

      The function needs to know that tabs separate the fields

    4. D

      The function imports only numerical columns by default

    Correct answer
    C

    The function needs to know that tabs separate the fields

    Explanation

    For a tab-delimited file, the separator argument tells R that tabs divide the fields, allowing the file to be read correctly.

  69. 69

    What is hierarchical clustering intended to identify?

    1. A

      Groups of observations that are similar to one another

    2. B

      The exact causal effect of one variable on another

    3. C

      The numerical order of variables in a data frame

    4. D

      The optimal package for importing a spreadsheet

    Correct answer
    A

    Groups of observations that are similar to one another

    Explanation

    Hierarchical clustering groups observations according to their similarity or distance on selected variables.

  70. 70

    What is the difference between divisive and agglomerative clustering?

    1. A

      Divisive starts separately and merges; agglomerative starts together and splits

    2. B

      Divisive starts with one group and splits; agglomerative starts separately and merges

    3. C

      Divisive uses categorical data only; agglomerative uses quantitative data only

    4. D

      Divisive predicts outcomes; agglomerative estimates regression coefficients

    Correct answer
    B

    Divisive starts with one group and splits; agglomerative starts separately and merges

    Explanation

    Divisive clustering begins with all observations together and splits them, whereas agglomerative clustering begins with separate observations and combines them.

  71. 71

    What does a dendrogram display?

    1. A

      The standard errors of variables in a regression model

    2. B

      The individual values of a single histogram bin

    3. C

      The sequence of splits or merges that form hierarchical clusters

    4. D

      The frequency of categories in a factor

    Correct answer
    C

    The sequence of splits or merges that form hierarchical clusters

    Explanation

    A dendrogram displays the tree-like structure showing how observations or groups split or join during hierarchical clustering.

  72. 72

    What determines the validity of a particular clustering result?

    1. A

      Only the number of colors used in the dendrogram

    2. B

      The operating system on which the analysis was run

    3. C

      The observations, variables, distance measure, and method used

    4. D

      Only the names of the observations in the original data set

    Correct answer
    C

    The observations, variables, distance measure, and method used

    Explanation

    Clustering depends on the supplied observations, selected variables, similarity or distance measure, and clustering method; changing them can change the result.

  73. 73

    What is principal component analysis primarily used for?

    1. A

      Counting the observations in each categorical group

    2. B

      Importing Excel files into a data frame

    3. C

      Testing whether two category labels are spelled identically

    4. D

      Reducing dimensionality while retaining important variation

    Correct answer
    D

    Reducing dimensionality while retaining important variation

    Explanation

    PCA is a dimensionality-reduction method intended to simplify data while preserving important information.

  74. 74

    What does centering variables accomplish in PCA?

    1. A

      It shifts variables so their means are zero

    2. B

      It removes all observations with unusually large scores

    3. C

      It forces every variable to have the same maximum value

    4. D

      It changes every variable into a categorical factor

    Correct answer
    A

    It shifts variables so their means are zero

    Explanation

    Centering moves the variables so that their means are zero.

  75. 75

    What does scaling variables accomplish in PCA?

    1. A

      It guarantees that every component explains equal variation

    2. B

      It places variables on a comparable scale, commonly with unit variance

    3. C

      It converts every variable into a text string

    4. D

      It reduces the number of observations to one per variable

    Correct answer
    B

    It places variables on a comparable scale, commonly with unit variance

    Explanation

    Scaling adjusts the variables so differences in measurement scale do not allow one variable to dominate the analysis.

  76. 76

    How many principal components can PCA produce relative to the original variables?

    1. A

      It produces components only for categorical variables

    2. B

      It always produces exactly one component

    3. C

      It always produces twice as many components as variables

    4. D

      It can produce the same number of components as original variables

    Correct answer
    D

    It can produce the same number of components as original variables

    Explanation

    In the example, nine original variables produced nine components, although only the first few appeared important.

  77. 77

    What does a PCA scree plot help the analyst evaluate?

    1. A

      Whether a histogram has the correct axis label

    2. B

      How much variation each principal component explains

    3. C

      Which rows contain missing values in a CSV file

    4. D

      How many categories occur in a factor

    Correct answer
    B

    How much variation each principal component explains

    Explanation

    A scree plot displays the relative importance or explained variation associated with the components.

  78. 78

    What does the rotation matrix in PCA describe?

    1. A

      The number of rows and columns in the original matrix

    2. B

      Associations between original variables and principal components

    3. C

      The order in which cases were entered into the data set

    4. D

      The geographic rotation of the plotting window

    Correct answer
    B

    Associations between original variables and principal components

    Explanation

    The rotation values indicate how strongly each original variable is associated with each component and can be interpreted similarly to correlations.

  79. 79

    What does a PCA biplot display in the example?

    1. A

      Only the original raw variables in separate histograms

    2. B

      The package installation history for the analysis

    3. C

      Cases and variable directions on the first two principal components

    4. D

      Only the regression residuals for each observation

    Correct answer
    C

    Cases and variable directions on the first two principal components

    Explanation

    The biplot shows cases in the space of the first two components and uses lines to indicate the approximate directions of variable contributions.

  80. 80

    What is the central purpose of regression?

    1. A

      Using one or more predictors to predict a particular outcome

    2. B

      Displaying the distribution of one variable without modeling

    3. C

      Converting all variables into equally spaced categories

    4. D

      Grouping observations without defining a predicted outcome

    Correct answer
    A

    Using one or more predictors to predict a particular outcome

    Explanation

    Regression uses multiple variables simultaneously to predict scores on one outcome variable.

  81. 81

    In an R linear model formula, what does the tilde indicate?

    1. A

      The data should be sorted in descending order

    2. B

      The package should be installed from CRAN

    3. C

      The variables should be converted to character values

    4. D

      The outcome is modeled as a function of the predictors

    Correct answer
    D

    The outcome is modeled as a function of the predictors

    Explanation

    In a formula such as outcome tilde predictors, the tilde separates the dependent outcome from the variables used to predict it.

  82. 82

    What is simultaneous-entry regression?

    1. A

      Entering one predictor only after removing the outcome variable

    2. B

      Entering observations into separate clusters before modeling

    3. C

      Entering all selected predictor variables into one model at once

    4. D

      Entering variables in alphabetical order without estimating coefficients

    Correct answer
    C

    Entering all selected predictor variables into one model at once

    Explanation

    Simultaneous entry uses all of the selected predictor variables together in one regression equation.

  83. 83

    What does the intercept represent in a linear regression model?

    1. A

      The predicted outcome when all predictors equal zero

    2. B

      The number of observations classified as outliers

    3. C

      The proportion of variance explained by the residuals

    4. D

      The average of all predictor variables combined

    Correct answer
    A

    The predicted outcome when all predictors equal zero

    Explanation

    The intercept is the model's predicted outcome at the point where all predictors have values of zero.

  84. 84

    What does multiple R2R^2R2 indicate in a regression model?

    1. A

      The number of predictors that have statistically significant coefficients

    2. B

      How well the predictors collectively account for variation in the outcome

    3. C

      The number of cases excluded from the regression analysis

    4. D

      The exact value of the intercept when all predictors are zero

    Correct answer
    B

    How well the predictors collectively account for variation in the outcome

    Explanation

    Multiple R2R^2R2 summarizes the collective predictive ability of the predictors for the outcome.

  85. 85

    What information does a regression summary provide for individual coefficients?

    1. A

      Coefficient estimates, standard errors, test statistics, and probability values

    2. B

      Only the number of rows and columns in the data frame

    3. C

      Only the names of the variables and their data types

    4. D

      Only the frequencies of categorical predictors

    Correct answer
    A

    Coefficient estimates, standard errors, test statistics, and probability values

    Explanation

    A regression summary reports coefficient estimates along with standard errors, t tests, and p-values.

  86. 86

    What do asterisks commonly indicate in an R regression summary?

    1. A

      Rows that were selected using a categorical condition

    2. B

      Variables that were automatically converted to character type

    3. C

      Statistical significance levels associated with probability values

    4. D

      Packages that failed to load during installation

    Correct answer
    C

    Statistical significance levels associated with probability values

    Explanation

    Asterisks in the regression summary mark probability values at conventional significance levels, including the commonly used cutoff of 0.050.050.05.

  87. 87

    What is a residual in regression?

    1. A

      The first principal component extracted from the predictors

    2. B

      The number of categories in the dependent variable

    3. C

      The difference between an observed outcome and its predicted value

    4. D

      The average value of all predictor variables

    Correct answer
    C

    The difference between an observed outcome and its predicted value

    Explanation

    A residual represents the prediction error for an observation: its observed outcome minus the model's predicted outcome.

  88. 88

    What is the lasso method?

    1. A

      A clustering method that begins with one group

    2. B

      The least absolute shrinkage and selection operator

    3. C

      A method for importing tab-delimited text files

    4. D

      A graphic for displaying categorical frequencies

    Correct answer
    B

    The least absolute shrinkage and selection operator

    Explanation

    Lasso is an acronym for least absolute shrinkage and selection operator and is one of the regression approaches available in R.

  89. 89

    How does stepwise regression differ conceptually from simultaneous entry?

    1. A

      Stepwise procedures select or add predictors in stages rather than entering all at once

    2. B

      Stepwise procedures are used only for plotting, while simultaneous entry imports data

    3. C

      Stepwise procedures require categorical data, while simultaneous entry requires text data

    4. D

      Stepwise procedures use no outcome variable, while simultaneous entry does

    Correct answer
    A

    Stepwise procedures select or add predictors in stages rather than entering all at once

    Explanation

    Stepwise regression adds or selects predictors in stages, whereas simultaneous entry places all selected predictors into the model at once.

Question 1 of 89
Question 1 of 89

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent