1. Home
  2. Explore
  3. Statistics
  4. R Statistics and Machine Learning

Study methods

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

R Statistics and Machine Learning

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

Why is the ability to work with data considered an increasingly important skill?

Tap to flipClick to flipspace

It helps people understand, process, extract value from, visualize, and communicate data.

Or swipe the card

125 cards

  1. Why is the ability to work with data considered an increasingly important skill?

    It helps people understand, process, extract value from, visualize, and communicate data.

  2. How can programming support reproducibility in research?

    A script records the steps used to process data and run analyses, so the workflow and results can be reproduced.

  3. How can programming reduce repetitive work in data analysis?

    It can automate preprocessing, analyses, and graph production, avoiding repeated manual steps such as clicking through menus.

  4. How do scripts improve communication about an analysis?

    They show the exact operations performed on the data, helping others understand, review, and run the analysis.

  5. Why might a scripted workflow be more useful than relying only on statistical software menus?

    Scripts can bring data preprocessing and analysis together in one documented, repeatable workflow and handle complex or repeated analyses more easily.

  6. What does it mean that R is open source?

    Its source is available for people to use and contribute to, including by developing or updating packages.

  7. What are key practical advantages of R for students and researchers?

    R is free, has a large community and many packages, and runs on Windows, macOS, and Linux.

  8. Why is R useful for statistical methods and newer algorithms?

    Its community contributes packages implementing statistical methods and algorithms, including methods that may not be available in some menu-based software.

  9. What is the significance of R being a scripting language?

    Analyses can be written as scripts, which supports automation, communication, and reproducibility.

  10. What does it mean that R is flexible and extensible?

    Users can customize workflows and write their own functions or algorithms for a project.

  11. Why was R presented as a suitable language for a statistics-focused workshop?

    R was designed specifically for statistical work, making it well suited to the workshop's analysis needs.

  12. How should big data relate to traditional data collection and analysis?

    Big data and machine learning should supplement, not automatically replace, traditional data collection and analysis.

  13. What is RStudio, and why is it commonly used with R?

    RStudio is an integrated development environment (IDE) that provides one interface for writing and running R code and working with its outputs.

  14. Why does R benefit from an IDE such as RStudio?

    R is a scripting language; an IDE provides a convenient interface for editing scripts, using the console, and viewing results.

  15. What is the role of the RStudio text editor?

    It is used to write and edit scripts; entering text there alone does not run it.

  16. What is the role of the RStudio console?

    It is the command-line area where R commands can be entered and executed.

  17. What does the RStudio workspace or environment pane show?

    It shows objects such as variables currently available in the global environment.

  18. What can the RStudio Files, Help, and Plots pane be used for?

    It provides access to files and help, and displays plots and other output.

  19. How can R be used as a calculator?

    Enter arithmetic expressions in the console; R evaluates them and returns the result.

  20. What arithmetic operators were demonstrated in R?

    Addition with +, division with /, multiplication with *, and exponentiation with ^.

  21. How can logarithms and square roots be calculated in R?

    Use functions such as log() and sqrt().

  22. What does the R expression 50 == 50 + 1 return?

    FALSE, because the two sides are not equal.

  23. What kinds of comparisons and logical operations can R evaluate?

    It can test equality, inequality, and ordering (such as greater than or less than), and use AND, OR, and NOT logic.

  24. Is R case-sensitive?

    Yes. For example, X and x refer to different names.

  25. What are the two broad kinds of objects described in R?

    Data objects store information; functions act on data and return results or perform specified operations.

  26. What is a vector in R?

    A one-dimensional collection of values of the same type.

  27. What does the c() function do when creating a vector?

    It combines or concatenates values into a vector.

  28. What class does a vector of text values such as names have in R?

    Its class is character.

  29. What class does a vector of ordinary numeric measurements have in R?

    Its class is typically numeric.

  30. How can you check an object's class in R?

    Use class(object), such as class(names).

  31. What is a list in R?

    A structure that can combine objects of different types, such as a character vector and a numeric vector.

  32. What is a matrix in R?

    A two-dimensional structure organized into rows and columns, commonly important in statistical computations.

  33. How can a matrix's dimensions be specified when creating it?

    For example, use matrix(values, nrow = 4, ncol = 1) to specify four rows and one column.

  34. What is a data frame in R?

    A table-like structure containing variables as columns and observations as rows.

  35. How can vectors be combined as columns in a data frame?

    Use data.frame() with the vectors as arguments, such as data.frame(names, IQ.scores).

  36. What is the BMI formula used in the workshop?

    BMI is weight divided by height squared, with height measured in metres.

  37. What are the main parts of a user-defined R function?

    A function name, input arguments, and an expression or body specifying what to do with those arguments.

  38. What does an argument represent in an R function?

    An input value or data item that the function can use.

  39. How is a function assigned to a name in R?

    Use an assignment, such as greeting <- function() { ... }.

  40. How do you call a function that has no arguments?

    Use its name followed by empty parentheses, such as greeting().

  41. How are literal text strings distinguished from variable names in R code?

    Text strings are enclosed in quotation marks, such as "Hello World!".

  42. What is the purpose of the print() function?

    It displays a value or message as output.

  43. How can a user-defined function calculate BMI?

    Give it height and weight as inputs, then calculate weight divided by height squared, using height in metres.

  44. How can an R function do more than return a calculated number?

    It can use conditional logic to evaluate the result and print an associated message.

  45. What is the purpose of an if statement in an R function?

    It checks whether a condition is true and runs specified code when it is.

  46. How do else if and else extend conditional logic?

    else if tests another condition when the preceding condition is false; else handles the remaining case.

  47. How can a function calculate the mean and standard deviation of a vector in R?

    Use mean(vector) and sd(vector).

  48. How can an R function make an output optional?

    Include a logical argument and use it to decide whether to produce that output.

  49. What does a default argument value such as print.median = FALSE do?

    It makes the median output optional and turned off unless the caller explicitly sets the argument to TRUE.

  50. Why should function-body commands be clearly separated, often onto new lines?

    Clear separation helps R identify where one command ends and the next begins.

  51. What is the purpose of the tidyverse package collection?

    It provides packages for importing, cleaning, transforming, manipulating, and visualizing data.

  52. What is the difference between installing and loading an R package?

    Installing downloads the package to the computer; loading makes an installed package available in the current R session.

  53. How do you load an installed package in R?

    Use library(package_name), for example library(tidyverse).

  54. Which tidyverse package is used for visualization?

    ggplot2.

  55. Which tidyverse package is used to import data?

    readr.

  56. Which tidyverse package is used to manipulate data tables?

    dplyr.

  57. Which tidyverse package is used to tidy or clean data?

    tidyr.

  58. What is the general sequence of the data model described in the workshop?

    Import data, tidy and transform it, visualize it, model it, assess whether further analysis is needed, and communicate the results.

  59. Why are importing, tidying, and transforming data important parts of analysis?

    They prepare raw data for analysis; data work involves more than fitting a statistical model.

  60. What does read_csv() do?

    It reads a CSV file into R; it is the tidyverse function for this task.

  61. How can you inspect a data frame in an RStudio table viewer?

    Use View(data_frame).

  62. What does dim(data) return?

    The dimensions of the data, such as its number of rows and columns.

  63. What do head(data) and tail(data) show?

    head() shows the first rows (six by default); tail() shows the last rows (six by default).

  64. How can you obtain the variable names of a data frame?

    Use names(data_frame).

  65. What does NA represent in R?

    A missing or unavailable value.

  66. Why can mean() return NA when its input contains missing values?

    By default, mean() does not remove missing values, so a missing value in the vector prevents an ordinary numeric mean from being returned.

  67. How can mean() calculate a mean while ignoring missing values?

    Set na.rm = TRUE, as in mean(age, na.rm = TRUE).

  68. What is the default setting of na.rm in mean()?

    FALSE, so missing values are not removed by default.

  69. How can filter() be used to retain only observations from a particular year?

    Apply a condition such as filter(data, year == 2007) to keep rows whose year is 2007.

  70. How can filter() select observations from Asia?

    Use a condition on the continent variable, such as filter(data, continent == "Asia").

  71. How can filter() select observations above a population threshold?

    Use a greater-than condition on the population variable, such as filter(data, pop > threshold).

  72. Why is data visualization useful for communicating data?

    Visual displays can convey patterns and concepts quickly and vividly, often more readily than a lengthy text report.

  73. What is ggplot2 designed to do?

    Create visualizations by combining graphical components in layers.

  74. What information is specified by ggplot(data, aes(x = ..., y = ...))?

    The data set and the mapping of variables to visual properties such as the x- and y-axes.

  75. What does geom_point() add to a ggplot?

    A scatter plot layer, with a point representing each observation according to the mapped variables.

  76. What does the alpha setting control for points in a plot?

    Transparency: a lower alpha makes points more transparent, while an alpha of 1 makes them opaque.

  77. What does the size setting control for points in a plot?

    The size of the plotted points.

  78. How can continent membership be shown by point color in a ggplot?

    Map the continent variable to color, for example with aes(color = continent).

  79. What does a box plot help show when comparing life expectancy across continents?

    It summarizes and compares the distributions of values across groups, including their central tendency and spread.

  80. What does a histogram show?

    The distribution of a numeric variable by displaying counts across value ranges.

  81. What is an outlier in the context of a plotted data distribution?

    An observation that lies apart from the main pattern of the data.

  82. What broad relationship did the GDP-per-capita versus life-expectancy visualization suggest?

    Life expectancy tended to be higher where GDP per capita was higher.

  83. How can a multi-variable visualization reveal more than a simple x-y relationship?

    Additional visual mappings, such as color for continent or point size for population, can show group patterns and other relationships.

  84. What does summary(data) provide?

    A summary of each variable, with statistics appropriate to its type, such as descriptive statistics for numeric variables.

  85. How can summaries be calculated separately for groups in R?

    Use by() with a grouping variable and a summary function, such as summarizing data by continent.

  86. What does the $ operator do when used with a data frame?

    It selects a named variable or column, such as data$country.

  87. What does unique() return?

    The distinct values found in an object, such as the unique country names in a variable.

  88. How can you count the number of unique countries in a data set?

    Apply unique() to the country variable and then use length() on the result.

  89. What does length() return?

    The number of elements in a vector.

  90. What does the cor() function calculate?

    The correlation between numeric variables; the workshop example found a life-expectancy and GDP-per-capita correlation of about 0.58.

  91. What question can an independent-samples t-test address in the country data example?

    Whether mean life expectancy differs between two groups, such as Europe and Asia.

  92. What did the Europe-versus-Asia life-expectancy t-test indicate in the example?

    The result indicated higher life expectancy in Europe than in Asia, with a statistically significant difference.

  93. What does as.factor() do when applied to a numeric year variable?

    It converts the variable to a factor so its values can be treated as categories.

  94. What does paired = TRUE specify in a t-test?

    It requests a paired-samples t-test, appropriate for comparing linked or matched observations.

  95. What comparison was made with a paired t-test in the year example?

    Life expectancy values for 2002 were compared with values for 2007 using a paired test.

  96. What does lm() do in R?

    It fits a linear model, such as a model predicting life expectancy from population, GDP per capita, and year.

  97. What does summary(model) provide for a fitted linear model?

    Model information including coefficient estimates, test statistics, p-values, residual summaries, and measures of model fit.

  98. What do residuals represent in a fitted model?

    The parts of the observed data not explained by the model.

  99. What does adjusted R2R^2R2 describe in a linear-model summary?

    The proportion of variation in the outcome explained by the model, adjusted for the number of predictors; the example value of 0.4392 was interpreted as about 44%.

  100. How can a model's coefficients be extracted in R?

    Use the model's $coefficients component, such as model$coefficients.

  101. Why can scripts be more flexible than menu-based software for complex models?

    Scripts can extract specific model components and automate or customize analyses in ways that may be difficult through menus.

  102. What is big data in contrast to typical experiment-generated data, as described in the workshop?

    Experiment data often have many subjects and relatively few variables, whereas big data may have many variables but comparatively fewer subjects.

  103. What do NNN and PPP represent in the data-dimensions comparison?

    NNN represents the number of subjects or observations; PPP represents the number of variables or features.

  104. Why can big-data analysis require feature reduction or selection?

    Big data can contain many variables, so selecting or reducing features can make prediction and analysis more manageable.

  105. What kinds of sources can generate large data sets?

    Examples include brain imaging such as fMRI or EEG, genome data, wearable devices, and social networks.

  106. How can wearable devices contribute to research data?

    They can collect repeated measurements, such as heart-rate data, which can then be analyzed.

  107. What is machine learning, in general terms?

    A set of general algorithms that learn patterns from data rather than being programmed with a fixed, phenomenon-specific set of instructions.

  108. How can the amount of informative data affect machine-learning performance?

    More informative data can help an algorithm learn and may improve its performance.

  109. What is classification in machine learning?

    Assigning an observation to a category based on its features.

  110. What does a classification model use to assign an observation to a class?

    The observation's features and the learned relationships between features and known classes.

  111. What is regression in machine learning?

    Learning a model from existing samples to predict an outcome for new samples.

  112. What is clustering?

    Grouping observations to discover similarities, differences, or hidden patterns in the data.

  113. What is the difference between supervised and unsupervised learning?

    Supervised learning uses input and output information to build predictive models; unsupervised learning looks for structure using input data without output labels.

  114. Which common machine-learning tasks are supervised?

    Classification and regression.

  115. Which common machine-learning task is unsupervised?

    Clustering.

  116. How do classification and clustering differ?

    Classification assigns observations to defined categories using labeled examples; clustering discovers groupings from data without using output labels.

  117. What is statistical inference intended to do?

    Use a mathematical model of the data-generating process to test hypotheses or understand how a system behaves.

  118. What is prediction intended to do?

    Forecast an unobserved outcome or future behavior from available information.

  119. How are classical statistics and machine learning often characterized in relation to inference and prediction?

    Classical statistics is often emphasized for inference and understanding; machine learning is often emphasized for prediction, though the boundary is not clear-cut.

  120. What assumption does the idea of 'big data hubris' criticize?

    The assumption that having more data automatically makes the data or conclusions better.

  121. What happened in the Google Flu Trends example after media attention increased public awareness?

    People began searching for flu-related terms more often, including when they did not necessarily have flu symptoms, and the system later overestimated flu activity relative to CDC data.

  122. What lesson does the Google Flu Trends example illustrate?

    Data patterns can change when people react to a prediction system or publicity about it; more data is not necessarily better data.

  123. How can big data be useful for generating research hypotheses?

    It can reveal patterns and suggest novel hypotheses that can later be tested in experiments.

  124. Why should researchers examine the legitimacy of a method used with big data?

    A large data set does not by itself ensure that the method or conclusions are valid.

  125. What practices support clear communication and reproducibility in R scripts?

    Follow a consistent style, add comments explaining the code, and use tools such as R Markdown to combine code and results in a document.

Card 1 of 125
Card 1 of 125

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent