Introduction to R Programming for Data Science Week 2 Answers

                     

Course Name: Introduction to R Programming for Data Science

Course Link: Click Here

These are answers of Introduction to R Programming for Data Science Week 2


Practice Quiz

Q1. What is the difference between the expression c(1, 2, 3, 4, 5) and the expression c(5:1)?
a. They both produce a factor with five numbers but the first is in ascending order and the second is in descending order.
b. The two expressions produce the same result.
c. One produces a factor and the other produces a vector.
d. They both produce a vector with five numbers but the first is in ascending order and the second is in descending order.

Answer: d. They both produce a vector with five numbers but the first is in ascending order and the second is in descending order.


Q2. Assume that the variable test_result contains the vector c(25, 35, 40, 50, 75). What is the result of the expression test_result[test_result < 50]?
a. [1] TRUE TRUE TRUE TRUE FALSE
b. [1] 25 35 40 50
c. [1] 25 35 40
d. [1] TRUE TRUE TRUE FALSE FALSE

Answer: c. [1] 25 35 40


These are answers of Introduction to R Programming for Data Science Week 2


Q3. What is the main difference between a list and a vector?
a. A list is a multi-dimensional array of values, while a vector is a single dimensional array of values.
b. A list can contain nominal or ordinal values, while a vector cannot.
c. It is not possible to add or remove items from a list, but you can do this with a vector.
d. A list can contain different types of data, while a vector may only contain one type of data.

Answer: d. A list can contain different types of data, while a vector may only contain one type of data.


Q4. What are three types of data you can store in an array or matrix? Select three answers.
a. Vectors
b. Integers
c. Numeric valus
d. Strings

Answer: b, c, d


These are answers of Introduction to R Programming for Data Science Week 2


Q5. In a data frame, each column is represented by a _________________ of values of the same data type.
a. Matrix
b. List
c. Variable
d. Vector

Answer: d. Vector


These are answers of Introduction to R Programming for Data Science Week 2


Graded Quiz

Q1. What is a nominal factor?
a. A factor with any type or number of elements.
b. A factor with ordering.
c. A factor with no implied order.
d. A factor that contains numeric data.

Answer: c. A factor with no implied order.


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)?
a. 40
b. 45
c. 35
d. 50

Answer: b. 45


These are answers of Introduction to R Programming for Data Science Week 2


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?
a. employee[“age”] == 35
b. employee[age] <- 35
c. employee[“age”] <- 35
d. employee[age] = 35

Answer: c. employee[“age”] <- 35


Q4. What is the main difference between a matrix and an array?
a. A matrix can contain vectors, but an array can only contain strings, characters, or integers.
b. A matrix can be arranged by rows or columns, but an array is always arranged by columns.
c. A matrix can contain multiple types of data, but an array can only contain data of the same type.
d. A matrix must be two dimensional, but an array can be single, two dimensional, or more than two dimensional.

Answer: d. A matrix must be two dimensional, but an array can be single, two dimensional, or more than two dimensional.


These are answers of Introduction to R Programming for Data Science Week 2


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?
a. employee[title]
b. employee.title
c. employee[[3]]
d. employee$title

Answer: d. employee$title


These are answers of Introduction to R Programming for Data Science Week 2


* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first. COPYING MATERIALS IS STRICTLY PROHIBITED.


All weeks answers of Introduction to R Programming for Data Science: Click Here

These are answers of Introduction to R Programming for Data Science Week 2


More from PROGIEZ

These are answers of Introduction to R Programming for Data Science Week 2