menu

Data Types and Variables in R


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

Vector

List

Data frame

Array


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


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

Numeric

Integer

Character

Logical


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

na.omit()

complete.cases()

is.na()

drop_na()


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

NA

NaN

Inf

#NAME?


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

merge()

cbind()

rbind()

bind_rows()


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

NA

NaN

Inf

#NAME?


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

as.numeric()

as.character()

as.logical()

as.factor()


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

Vector

List

Data frame

Matrix


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