Top 100 R Language Interview Questions & Answers

R Language Questions

A list of Top asked R Language Questions and answers are given below

R Language Questions MCQs

Question#1 The four most frequently used types of data objects in R are vectors, matrices, data frames and __.

i)Function

ii)Lists

iii)Packages

iv)Interfaces

Answer-: Lists

Question#2 A __ is a set of elements appearing in rows and columns where the elements are of the same mode whether they are logical, numeric (integer or double), complex or character.

i)Vector

ii)Matrix

iii)Lists

iv)Data frames

Answer-: Matrix

Question#3 What is the simplest way of creating the vector?

i)C function

ii)Create

iii)Destroy

iv)Invalid

Answer-: C function

Question#4 Which function replicates elements of vectors?

i)C

ii)Rep

iii)Crep

iv)Grep

Answer-: Rep

Question#5 The __ function creates a regular sequence of values to form a vector.

i)sequel

ii)Rep

iii)seq

iv)Grep

Answer-: seq

Question#6 Which function is used to enter in data at the terminal?

i)Scanned

ii)Scnn

iii)Scan

iv)Sccn

Answer-: Scan

Question#7 Computation with vectors is achieved using an element-by-element operation for avoiding _.

i)Loops

ii)Functions

iii)Packages

iv)Interfaces

Answer-: Loops

Question#8 To bind a row onto an already existing matrix, the __ function can be used.

i)Rbind

ii)Sbnd

iii)Gbind

iv)Sbind

Answer-: Rbind

Question#9 Which of the following is a 3-dimensional dataset?

i)Eris

ii)Iris

iii)Toris

iv)Irisss

Answer-: Iris

Question#10 Which dimension corresponds to the explanatory variables collected for each species?

i)First

ii)Second

iii)Third

iv)Fifth

Answer-: Second

Question#11 Using the __ vector, we create a species factor and bind it to the columns of iris.df.

i)rnames

ii)snames

iii)jnames

iv)fnames

Answer-: snames

Question#12 Accessing elements is achieved through a process called __.

i)Outdexing

ii)Indexing

iii)Highlighting

iv)Scrapping

Answer-: Indexing

Question#13 Which are indexed by either row or column using a specific name or number?

i)Datasets

ii)Data frames

iii)Data

iv)Functions

Answer-: Data frames

Question#14 What should we use to access elements with a value greater than five?

i)Subsetting commands

ii)Use functions

iii)Packages

iv)Interfaces

Answer-: Subsetting commands

R language questions for experience

Question#15 Lists can be created using the _ function.

i)Matrix.li

ii)Matrix.lists

iii)Lists.matric

iv)List

Answer-: List

Question#16 First component of the list can be accessed by _.

i)Name of the component

ii)List name

iii)Function

iv)Package

Answer-: Name of the component

Question#17 How can we access the first component of the list?

i)Number of the position

ii)Function

iii)Package

iv)Tools

Answer-: Number of the position

Question#18 The first component can be accessed using __ operator.

i)Intraction

ii)Extraction

iii)AND

iv)OR

Answer-: Extraction

Question#19 To extract a sublist, we use _ brackets.

i)Flower

ii)Square

iii)Double

iv)Single

Answer-: Single

Question#20 The length of a list is __ to the number of components in that list.

i)Double

ii)Equal

iii)Triple

iv)One fourth

Answer-: Equal

Question#21 Which function can be used to determine the names assigned to a list?

i)Names

ii)Name

iii)Nam

iv)Nem

Answer-: Names

Question#22 Joining two lists can be achieved either using the _ function.

i)Concat

ii)Join

iii)Reduce

iv)Delete

Answer-: Concat

Question#23 Which function gives the list as output?

i)Spline

ii)Matrix

iii)Vector

iv)Alphabet

Answer-: Spline

Question#24 Density function gives output as __.

i)Matrix

ii)Lists

iii)Vector

iv)Number

Answer-: Lists

Question#25 Locator function gives output as _.

i)Matrix

ii)Lists

iii)Vector

iv)Number

Answer-: Lists

Question#26 The _ function returns a list of densities (y) corresponding to bin values (x).

i)Spline

ii)Density

iii)Lists

iv)Locator

Answer-: Spline

Question#27 Which of the following while loops will print numbers from 1 to 4?

i)x<-1 while(x < 5) {x <- x+1; print(x);}

ii)x<-1 while(x < 5) do { print(x); x <- x+1;}

iii)x<-1 while(x < 5) do {x <- x+1; print(x);}

iv)x<-1 while(x < 5) { print(x); x <- x+1;}

Answer-: x<-1 while(x < 5) { print(x); x <- x+1;}

Question#28 What would be the result of following code?

i)x <- c(“x”, “y”, “z”) as.logical(x)

ii)“x” “y” “z”

iii)NA NA NA

iv)NaN NaN NaN

v)x y z

Answer-: NA NA NA

Question#29 What command will you enter in the R console to get help on how to quit R?

i)help q

ii)man quit

iii)help(q)

iv)info(quit)

Answer-: help(q)

Question#30Which of the following statements is correct?

i)Control structures like if, while, and for are used to control the flow of an R program

ii)The only way to exit a repeat loop is to call break

iii)Infinite loops should generally be avoided

iv)All the options

Answer-: All the options

R language questions for Freshers

Question#31 What is the output of the R code?
m <- c(1, 2, 3) n <- c(6, 5, 4) (m < 2) & (n > 5)

i)An error is thrown because the wrong operator is used

ii){1 2 4}

iii)True

iv)TRUE FALSE FALSE

Answer-: True

Question#32 In R, the subsequent data types are all atomic data types except _.

i)Logical

ii)Data frame

iii)Float

iv)Character

Answer-: Data frame

Question#33 What would be the result of following code?
x <- 0:4 as.logical(x)

i)FALSE TRUE TRUE TRUE TRUE

ii)“0” “1” “2” “3” “4”

iii)NA NA NA NA NA

iv)0 1 2 3 4

Answer-: FALSE TRUE TRUE TRUE TRUE

Question#34 What is the class of the object defined by the expression x<- c(4,”a”,TRUE) in R?

i)Integer

ii)Logical

iii)Character

iv)Numeric

v)Float

Answer-: Character

Question#35 Which of the following statements is correct?

i)Use explicit TRUE and FALSE values when indicating logical values

ii)R operates on named data structures

iii)rm command is used to remove objects in R

iv)All the options

Answer-: All the options

Question#36 Which of the following statements is correct?

i)NaN can also be thought of as a missing value

ii)Number Inf represents infinity in R

iii)The value Nan represents undefined value

iv)All the options

Answer-: The value Nan represents undefined value

Question#37 What would be the output of the subsequent code?
x <- c(“a”, “b”, “c”, “c”, “d”, “a”) x[c(1, 3, 4)]

i)“a” “b” “c”

ii)“b” “c” “d”

iii)“a” “c” “c”

iv)“a” “c” “d”

Answer-: “a” “c” “c”

Question#38 Assume that you have a vector x <- c(3,5,1,10,12,6) and you wish to set all elements of this vector that are smaller than 6 to be equal to 0, what R code accomplishes this?

i)x[x==0]

ii)x[x==6]<-0

iii)x[x<6]==0

iv)x[x<6]<-0

Answer-: x[x<6]<-0

Question#39 If I have two vectors, x<-c(1,3,5) and y<-c(3,2,10), what does rbind(x,y) give?

i)A vector length of 3

ii)A 3 x 3 matrix

iii)A 3 x 2 matrix

iv)A 2 x 3 matrix

v)A vector length of 2

Answer-: A 2 x 3 matrix

Question#40 Which function is used to generate Sequences in R?

i)sequence()

ii)order()

iii)seqn()

iv)seq()

Answer-: seq()

Question#41 An important property of vectors in R is that _.

i)A vector cannot have attributes like dimensions

ii)Elements can only be character or numeric

iii)All elements must be of the same class

iv)Elements can be of different classes

Answer-: All elements must be of the same class

R language questions MCQ with explanation

Question#42 Which command allows you to get the median tree Height of the R sample dataset “trees”?

i)median(trees$Height)

ii)median(trees.Height)

iii)median(trees)

iv)avg.median(trees$Height)

Answer-: median(trees$Height)

Question#43 Which R command creates a 2 by 2 matrix with the values 1, 2, 3, and 4?

i)m <- [1,2,;3,4]

ii)m <- matrix ( 1 -> 4; 2, 2)

iii)m <- matrix(1:4, 2, 2)

iv)m <- cbin( c(1,2),c(2,1) )

Answer-: m <- matrix(1:4, 2, 2)

Question#44 What would be the result of following code?
x <- 4 class(x)

i)integer

ii)numeric

iii)double

iv)real

Answer-: numeric

Question#45 Which function can be used to create collection of vectors objects?

i)cp()

ii)c()

iii)concat()

iv)None of the options

Answer-: c()

Question#46 What is the function in R to get the # of observations in a data frame?

i)nrow()

ii)nobs()

iii)n()

iv)ntotal()

Answer-: nrow()

Question#47 Which of the following statement would print “0” “1” “2” “3” “4” “5” “6” for the following R code?

x <- 0:6

i)as.character(x)

ii)as.logical(x)

iii)as.numeric(x)

iv)as.num(y)

Answer-: as.character(x)

Question#48 Point out the correct statement?

i)rep() is be used for replicating an object in various complicated ways

ii)seq() function has four arguments

iii)sequence() is a more general facility for generating sequences

iv)numerical vectors are generated by conditions

Answer-: rep() is be used for replicating an object in various complicated ways

Question#49 What will be the output of the following R code?
x <- c(“a”, “b”, “c”) > as.numeric(x)

i)Warning

ii)Error

iii)Abnormal termination

iv)Prints x

Answer-: Warning

Question#50 What will be the output of the following R code?

x <- c(“a”, “b”, “c”) > as.logical(x)

i)a b c

ii)NA NA NA

iii)0 1 2

iv)6 8 9

Answer-: NA NA NA

Question#51 Point out the correct statement?

i)The elements of a logical vector cannot have the values TRUE, FALSE, and NA

ii)Matrices are vectors with a dimension attribute

iii)Numerical vectors are generated by conditions

iv)seq() function has four arguments

Answer-: Matrices are vectors with a dimension attribute

Question#52 Which of the following is invalid assignment?

i)> m <- matrix(nrow = 2, ncol = 3)

ii)> m <- matrix(nrow = 2, ncol = 3.5)

iii)> m <- mat(nrow = 2, ncol = 5)

iv)> m <- mat(nrow = 2, ncol = 3)

Answer-: > m <- matrix(nrow = 2, ncol = 3)

Question#53 What will be the output of the following R code?

m <- matrix(nrow = 2, ncol = 3)
dim(m)

i)3 2

ii)2 3

iii)2 2

iv)4 5

Answer-: 2 3

Question#54 What will be the output of the following R code?

m <- 1:10
m

i)1 2 3 4 5 6 7 8 9 10

ii)1 2 3 4 5 6 7 8 9 10 11

iii)0 1 2 3 4 5 6 7 8 9 10

iv)10 9 8 6 5 4 2 3 1 2

Answer-: 1 2 3 4 5 6 7 8 9 10

Question#55 R has how many atomic classes of objects?

i)1

ii)2

iii)3

iv)5

Answer-: 5

Q56 Point out the correct statement?

i)Empty vectors can be created with the vector() function

ii)A sequence is represented as a vector but can contain objects of different classes

iii)“raw” objects are commonly used directly in data analysis

iv)The value NaN represents undefined value

Answer-: Empty vectors can be created with the vector() function

Question#57 Numbers in R are generally treated as _ precision real numbers.

i)double

ii)single

iii)real

iv)imaginary

Answer-: double

Question#58 If you explicitly want an integer, you need to specify the _ suffix.

i)D

ii)R

iii)L

iv)K

Answer-: L

Question#59 Point out the correct statement?

i)The value NaN represents undefined value

ii)Number Inf represents infinity in R

iii)NaN can also be thought of as a missing value

iv)“raw” objects are commonly used directly in data analysis

Answer-: Number Inf represents infinity in R

Question#60 Attributes of an object (if any) can be accessed using the __ function.

i)objects()

ii)attrib()

iii)attributes()

iv)obj()

Answer-: attributes()

Question#61 R objects can have attributes, which are like __ for the object.

i)metadata

ii)expression

iii)features

iv)dimensions

Answer-: metadata

Question#62 Which of the following can be considered as object attribute?

i)dimensions

ii)class

iii)length

iv)all of the mentioned

Answer-: all of the mentioned

Question#63 The __ function can be used to create vectors of objects by concatenating things together.

i)cp()

ii)c()

iii)concat()

iv)con()

Answer-: c()

Question#64 What will be the output of the following R code?

x <- vector(“numeric”, length = 10)
x

i)10

ii)0 0 0 0 0 0 0 0 0 0

iii)0 1

iv)00120

Answer-: 0 0 0 0 0 0 0 0 0 0

Question#65 Which of the following statement is invalid?

i)x >- c(1+0i, 2+4i)

ii)x >- c(TRUE, FALSE)

iii)x >- c(T, F)

iv)None of the mentioned

Answer-: None of the mentioned

Question#66 Point out the correct statement?

i)Use explicit TRUE and FALSE values when indicating logical values

ii)rm command is used to remove objects in R

iii)R operates on named data structures

iv)All of the mentioned

Answer-: All of the mentioned

Question#67 What will be the output of the following R code?

x <- 6
class(x)

i)“integer”

ii)“numeric”

iii)“real”

iv)“imaginary”

Answer-: “numeric”

Question#68 Point out the correct statement?

i)The usual operator, <-, can be thought of as a syntactic shortcut to expression operation

ii)Assignment can also be made using the function assignment()

iii)Vectors can be used in arithmetic expressions, in which case the operations are performed element by element

iv)seq() is used to delete the numbers

Answer-: Vectors can be used in arithmetic expressions, in which case the operations are performed element by element

Question#69 Which of the following is invalid assignment?

i)> c(10.4, 5.6, 3.1, 6.4, 21.7) -> x

ii)> assign(“x”, c(10.4, 5.6, 3.1, 6.4, 21.7))

iii)> x <- c(10.4, 5.6, 3.1, 6.4, 21.7)

iv)None of the mentioned

Answer-: None of the mentioned

Question#70 What will be the output of the following R code?

sqrt(-17)

i)-4.02

ii)4.02

iii)NaN

iv)3.67

Answer-: NaN

Question#71 _ function returns a vector of the same size as x with the elements arranged in increasing order.

i)sort()

ii)orderasc()

iii)orderby()

iv)sequence()

Answer-: sort()

Question#72 Which of the following code constructs vector of length 11?

i)> v <- 3*x + y + 1

ii)> v <- 3*x + y + 2

iii)> v <- 2*x + y + 1

iv)> v <- 2*x + y + 4

Answer-: > v <- 2*x + y + 1

Question#73 Find the following type of vector?
a <- c(1,2,5.3,6,-2,4)

i)Numeric

ii)Character

iii)Integer

iv)Logical

Answer-: Numeric

Question#74 All columns in a matrix must have the same mode and the _ length.

i)Different

ii)Same

iii)May be the same

iv)May be different

Answer-: Same

Question#75 _ provides optional labels with the columns and rows.

i)Disnames

ii)Dimnames

iii)Denmes

iv)Demnesd

Answer-: Dimnames

Question#76 __ are similar to matrices but can have more than two dimensions.

i)Functions

ii)Packages

iii)Arrays

iv)Columns

Answer-: Arrays

Question#77 Which is more general than a matrix, in that different columns can have different modes?

i)Data types

ii)Data frames

iii)Data sets

iv)Databases

Answer-: Data sets

Question#78 An ordered collection of objects or components are called __.

i)Data frames

ii)Datasets

iii)Databases

iv)Lists

Answer-: Lists

Question#79 The __ stores the nominal values as a vector of integers in the range of 1 to unique values in the nominal variable.

i)Factor

ii)Matrix

iii)Lists

iv)Functions

Answer-: Factor

Question#80 An ordered factor is used to represent an __.

i)Ordinal variable

ii)Simple variable

iii)Coordinal variable

iv)Biordinal variable

Answer-: Ordinal variable

Question#81 On what basis of a variable, OS allocates memory and decides what can be stored in the reserved memory?

i)Data bases

ii)Data sets

iii)Data types

iv)Lists

Answer-: Data types

Question#82 The data type of the R-object becomes the data type of the __.

i)Functions

ii)Packages

iii)Variables

iv)Lists

Answer-: Variables

SAP S/4HANA Master Data Concepts Questions & Answers
SAP S/4HANA Functional Capabilities 1909 Questions & Answer
SAP S/4HANA Technical Capabilities 1909 Questions & Answers
SAP Implementation S/4HANA Project Management Questions & Answers
SAP S/4 HANA Enterprise Management – Sales Questions Answers
SAP S/4HANA Key Concepts Overview Questions & Answers
SAP S/4HANA Enterprise Structure Questions & Answer
SAP S/4HANA Reporting and Analytics Questions & Answers
SAP S/4HANA Navigation Interview Questions and Answers
SAP S/4HANA Awareness 1909 Questions and Answers

About Author


After years of Technical Work, I feel like an expert when it comes to Develop wordpress website. Check out How to Create a Wordpress Website in 5 Mins, and Earn Money Online Follow me on Facebook for all the latest updates.

1 thought on “Top 100 R Language Interview Questions & Answers”

  1. What a fantastic post! This is so chock full of useful information I can’t wait to dig deep and start utilizing the resources you have given me. Your exuberance is refreshing.

Leave a Comment