menu

Data Types and Variables in R

Data Types and Variables in R - Important Points


6. Which of the following data types is used to represent a two-dimensional table in R?

A. Vector

B. List

C. Data frame

D. Matrix

Discuss Work Space

Answer: option c

Explanation:

A data frame in R is used to represent a two-dimensional table.

7. Which of the following is a valid way to create a vector in R?

A. vec <- 1 2 3

B. vec <- c(1, 2, 3)

C. vec <- c(1 2 3)

D. vec <- [1, 2, 3]

Discuss Work Space

Answer: option b

Explanation:

To create a vector in R, we use the c() function and separate the elements with commas.

8. Which of the following is a valid way to create a list in R?

A. list <- c(1, "a", TRUE)

B. list <- list(1, "a", TRUE)

C. list <- [1, "a", TRUE]

D. list <- {1, "a", TRUE}

Discuss Work Space

Answer: option b

Explanation:

To create a list in R, we use the list() function and separate the elements with commas.

9. Which of the following is a valid way to create a data frame in R?

A. df <- data.frame(1, 2, 3)

B. df <- data.frame(c(1, 2, 3))

C. df <- data.frame(x = c(1, 2, 3), y = c("a", "b", "c"))

D. df <- data.frame(list(1, "a", TRUE))

Discuss Work Space

Answer: option c

Explanation:

To create a data frame in R, we use the data.frame() function and specify the column names and values.

10. Which of the following data types is used to represent missing or undefined values in R?

A. NA

B. NaN

C. Inf

D. #NAME?

Discuss Work Space

Answer: option a

Explanation:

NA is used in R to represent missing or undefined values.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now