menu

Data Types and Variables in R


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

NA

NaN

Inf

#NAME?


2. Which of the following functions is used to merge two data frames in R based on a common column?

merge()

cbind()

rbind()

bind_rows()


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

vec <- 1 2 3

vec <- c(1, 2, 3)

vec <- c(1 2 3)

vec <- [1, 2, 3]


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

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

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

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

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


5. Which of the following functions is used to sort a vector in ascending order in R?

sort()

order()

rank()

aggregate()


6. Which of the following data types is used to represent positive infinity in R?

NA

NaN

Inf

#NAME?


7. Which of the following data types is used to represent not-a-number values in R?

NA

NaN

Inf

#NAME?


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

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

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

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

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


9. Which of the following is not a basic data type in R?

Integer

Character

Logical

Matrix


10. Which of the following data types is used to represent a collection of objects of different types in R?

Vector

List

Data frame

Array