menu

Data Types and Variables in R


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

NA

NaN

Inf

#NAME?


2. Which of the following data types can store both numeric and character data?

Vector

List

Data frame

Matrix


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

typeof()

class()

str()

summary()


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


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

sort()

order()

rank()

aggregate()


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


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

2^31-1

2^32-1

2^63-1

There is no maximum length


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

Numeric

Integer

Character

Logical


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

merge()

cbind()

rbind()

bind_rows()