Introduction to R Programming for Data Science Quiz Answer

Introduction to R Programming for Data Science Week 01 Quiz Answers

Q1. R can perform several forms of statistical computation. What is an example of hypothesis testing?

  • Inferring an unknown mean value of a population from its samples.
  • Compute and visualize a correlation matrix among four different variables to see if they are correlated.
  • Obtaining a representative subset of data.
  • Testing if the mean values of two groups are statistically different.

Q2. Which of the following data type conversions may be not allowed in R?

  • integer (like 1L or 2L) to numeric
  • character (like `1`, `A`, or `test`) to numeric
  • logical (like TRUE or FALSE) to numeric
  • numeric (like 1 or 2) to integer

Q3. What is the result of the R expression 100 * (5 – 3)?

  • 503
  • 200
  • 497
  • 500

Q4. After you write code in an R script file or the R Console, what component of the R environment parses the code into objects in memory?

  • R Interpreter
  • R variables, functions, and datasets
  • R data files
  • R Workspace

Q5. Which features of RStudio help facilitate code writing? Select two answers.

  • Workspace visualization
  • Syntax highlighting
  • Code auto completion
  • File Explorer

Q6. True or False: Execution order does not matter when executing cells in a Jupyter notebook

  • True
  • False

Introduction to R Programming for Data Science Week 02 Quiz Answers

Q1. What is a nominal factor?

  • A factor with any type or number of elements.
  • A factor with ordering.
  • A factor with no implied order.
  • A factor that contains numeric data.

Q2. Assume that the variable test_result contains the vector c(25, 35, 40, 50, 75).What is the result of the expression mean(test_result)?

  • 50
  • 35
  • 45
  • 40

Q3. Assume you have variable called employee that contains the expression list(name = “Juan”, age = 30). What is the correct command to change the contents of the age item to 35?

  • employee[age] = 35
  • employee[age] <- 35
  • employee[“age”] == 35
  • employee[“age”] <- 35

Q4. What is the main difference between a matrix and an array?

  • A matrix can contain multiple types of data, but an array can only contain data of the same type.
  • A matrix must be two-dimensional, but an array can be single, two-dimensional, or more than two-dimensional.
  • A matrix can contain vectors, but an array can only contain strings, characters, or integers.
  • A matrix can be arranged by rows or columns, but an array is always arranged by columns.

Q5. Assume that you have a data frame called employee that contains three variables: name, age, and title. If you want to return all the values in the title variable, what command should you use?

  • employee.title
  • employee[3]
  • employee$title
  • employee[title]

Introduction to R Programming for Data Science Week 03 Quiz Answers

Q1. What is the result of the conditional statement 25 > 15 | 99 >= 100?

  • TRUE
  • FALSE

Q2. How do you define a global variable in a function?

  • Use the == assignment operator.
  • Use the -> assignment operator.
  • Use the <- assignment operator.
  • Use the <<- assignment operator.

Q3. You can use the str_sub() function to form a substring by counting back from the last position. This function is part of which package?

  • readr
  • stringr
  • tidyr
  • purrr

Q4. Assume you have a data frame that contains a string variable called ‘phone’. The phone numbers in this variable appear in (###) ###-#### or ###-###-#### format. Which feature of R can you use to isolate the area code (the three numbers between the parentheses or the first three numbers)?

  • It is not possible to do this using R.
  • A regular expression.
  • A mathematical operation.
  • A string operation.

Q5. When you convert a date in string format to a Date object, what information do you need to pass to the as.Date() function? Select two answers.

  • The number of days since January 1, 1970.
  • The date format of the string.
  • The UNIX format of the string.
  • The string containing the date.

Q6. What is the difference between an error and a warning in your R code?

  • An error halts code execution, while a warning does not.
  • You can catch an error, but you cannot catch a warning.
  • A warning halts code execution, while an error does not.
  • You can catch a warning, but you cannot catch an error.

Introduction to R Programming for Data Science Week 04 Quiz Answers

Q1. Assume you have read a .csv file into a data frame variable called employee. It has 20 rows of data and three variables: name, age, and title. What is the correct statement to use to return the fifth row of data in the name and title columns?

  • employee[5, 2:3]
  • employee[c(“name”, “title”), 5]
  • employee[2:3, 1:5]
  • employee[5, c(“name”, “title”)]

Q2. How do you return the number of characters in each paragraph of a text file that has been read into a character vector?

  • Use the nchar() function.
  • Use the file.size() function.
  • Use the scan() function.
  • Use the length() function.

Q3. Which package do you need to install before writing to an Excel file in R?

  • writexlsx
  • writexl
  • xlsx
  • No package is needed. This functionality is built into R.

Q4. You want to get a resource by its URL using an HTTP request and assign the HTTP response containing status code, headers, response body to a response variable. Which function should you use?

  • response <-POST(“https://www.mysite.com”)
  • response <-HEAD(“https://www.mysite.com”)
  • response <-PUT(“https://www.mysite.com”)
  • response <- GET(“https://www.mysite.com”)

Q5. After reading an HTML page from a URL, what must you do to get the <body> node from the root <html> node?

  • Use the html_node() function to return the <html> node.
  • Use the html_text() function to return the <body> node of the HTML.
  • Use the html_node() function to return the <body> as a child node of <html> node.
  • Use the html_text() function to return the <html> node.
Get all Course Quiz Answers of Applied Data Science with R Specialization

Introduction to R Programming for Data Science Coursera Quiz Answers

SQL for Data Science with R Coursera Quiz Answers

Data Analysis with R Coursera Quiz Answers

Data Visualization with R Coursera Quiz Answers

Data Science with R – Capstone Project Coursera Quiz Answers

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

2 Comments

  1. Why the Quiz answers were not shown, but just all questions and multiple choices? There is no answer highlighted for any questions. I am not sure if it the error of my side. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *