### Introduction to R Programming for Data Science Week 2 Answers

Course Name: Introduction to R Programming for Data Science

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.  TRUE TRUE TRUE TRUE FALSE
b.  25 35 40 50
c.  25 35 40
d.  TRUE TRUE TRUE FALSE FALSE

Answer: c.  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

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

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

#### 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

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

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[]
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.

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

## More from PROGIEZ

### Programming Data Structure And Algorithms Using Python | Week 2