# Introduction to R Programming for Data Science | week 2

## Practice Quiz

1. What is the difference between the expression c(1, 2, 3, 4, 5) and the expression c(5:1)?

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

One produces a factor and the other produces a vector.

The two expressions produce the same result.

They both produce a factor with five numbers but the first is in ascending order and the second is in descending order.

2. 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]?

[1] 25 35 40 50

[1] TRUE TRUE TRUE FALSE FALSE

[1] TRUE TRUE TRUE TRUE FALSE

[1] 25 35 40

3. What is the main difference between a list and a vector?

A list can contain nominal or ordinal values, while a vector cannot.

A list is a multi-dimensional array of values, while a vector is a single dimensional array of values.

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

It is not possible to add or remove items from a list, but you can do this with a vector.

4. In a data frame, each column is represented by a _________________ of values of the same data type.

List

Matrix

Variable

Vector

5. What are three types of data you can store in an array or matrix? Select three answers.

Numeric valus

Strings

Integers

Vectors

1. What is a nominal factor?

A factor with any type or number of elements.

A factor that contains numeric data.

A factor with ordering.

A factor with no implied order.

2. 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)?

45

35

50

40

3. 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

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

A matrix can contain vectors, but an array can only contain strings, characters, or integers.

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

A matrix can contain multiple types of data, but an array can only contain data of the same type.

A matrix can be arranged by rows or columns, but an array is always arranged by columns.

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

## More From Kuizzer

Introduction to R Programming for Data Science | week 1

Introduction to R Programming for Data Science | week 2

Introduction to R Programming for Data Science | week 3

Introduction to R Programming for Data Science | week 4

Introduction to R Programming for Data Science | week 5

Looks like you are using an ad-blocking browser extension. We request you to whitelist our website on the ad-blocking extension and refresh your browser to view the content.

2
0