menu

Data Types and Variables in R


1. What is the maximum length of a vector in R?

2^31-1

2^32-1

2^63-1

There is no maximum length


2. Which of the following data types is used to represent negative infinity in R?

NA

NaN

Inf

#NAME?


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

NA

NaN

Inf

#NAME?


4. Which of the following functions is used to check the data type of a variable in R?

typeof()

class()

str()

summary()


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

Vector

List

Data frame

Array


6. Which of the following functions is used to remove missing values from a vector in R?

na.omit()

complete.cases()

is.na()

drop_na()


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


8. What is the default data type of a variable in R?

Numeric

Integer

Character

Logical


9. Which of the following functions is used to convert a character variable to a numeric variable in R?

as.numeric()

as.character()

as.logical()

as.factor()


10. 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}