Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

51.

Which function is more verbose?(a) Lapply(b) Japply(c) Vapply(d) ZapplyThe question was posed to me in an interview for internship.The question is from Functions in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct ANSWER is (c) Vapply

To explain: If a programmer wants the output to be a LIST then lapply is used. vapply allows the programmer to specific the output TYPE. The DISADVANTAGE of using vapply is that it is very difficult to be IMPLEMENTED and more verbose.

52.

CRAN package ecosystem has more than ______ packages.(a) 5000(b) 4000(c) 6000(d) 8000I got this question during an interview.Question is from Functions in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Right choice is (c) 6000

Explanation: R language has several packages for SOLVING a PARTICULAR problem. CRAN package ECOSYSTEM has more than 6000 packages.

53.

Point out the wrong statement?(a) The primary task of debugging any R code is correctly diagnosing what the problem is(b) R provides only two tools to help you with debugging your code(c) print statement can be used for debugging purpose(d) The traceback() function must be called immediately after an error occursI have been asked this question during an internship interview.The doubt is from Debugging Tools in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct answer is (b) R provides only two TOOLS to HELP you with DEBUGGING your CODE

The best I can explain: R provides a number of tools to help you with debugging your code.

54.

Point out the correct statement?(a) An environment is a collection of (symbol, value) pairs, i.e. x is a symbol and 3.14 might be its value(b) If the value of a symbol is not found in the environment in which a function was defined, then the search is continued in the child environment(c) After the top-level environment, the search continues down the search list until we hit the parent environment(d) Dynamic scoping turns out to be particularly useful for simplifying statistical computationsThis question was addressed to me in homework.This interesting question is from Scoping Rules topic in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct choice is (a) An environment is a COLLECTION of (SYMBOL, value) pairs, i.e. X is a symbol and 3.14 might be its value

The explanation is: Every environment has a parent environment and it is POSSIBLE for an environment to have multiple “CHILDREN”.

55.

Which of the following language supports lexical scoping?(a) Perl(b) Python(c) Common Lisp(d) All of the mentionedI had been asked this question by my college director while I was bunking the class.My question is based upon Scoping Rules in section Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct ANSWER is (d) All of the mentioned

To explain: Lexical scoping in R has CONSEQUENCES BEYOND how free VARIABLES are looked up.

56.

The current user defined objects like lists, vectors, etc. is referred to as __________ in the R language.(a) Work names(b) Work space(c) Environment(d) ConsoleThe question was asked by my school teacher while I was bunking the class.My doubt stems from Functions topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct option is (a) WORK names

Explanation: The current R working environment of the user which has user DEFINED objects like lists, vectors, etc. is referred to as WORKSPACE in R LANGUAGE. The workspace of R is flexible to all functions of statistics.

57.

_____________ function is preferred over sapply as vapply allows the programmer to specific the output type.(a) Lapply(b) Japply(c) Vapply(d) ZapplyI got this question at a job interview.This interesting question is from Functions topic in section Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer» RIGHT choice is (c) Vapply

Best EXPLANATION: Vapply is similar to SAPPLY, but has a pre-specified type of RETURN value, so it can be safer (and SOMETIMES faster) to use. simplify2array() is the utility called from sapply() when simplify is not false and is similarly called from mapply().
58.

What will be the class of the vector if you concatenate a number and a character?(a) Number(b) Character(c) Integer(d) No classThis question was addressed to me in homework.I'd like to ask this question from Functions topic in chapter Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct answer is (B) Character

For explanation I WOULD say: The class of the resulting VECTOR if you concatenate a NUMBER and a character is Character class. Decimal values are called NUMERIC in R. It is the default computational data type in R language.

59.

What will be the output of runif()?(a) Random number(b) Numbers(c) Character(d) Path generationI have been asked this question in semester exam.The query is from Functions topic in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct choice is (a) Random number

The best explanation: Random numbers from a normal distribution can be generated using runif() function. We can specify the range of the uniform distribution with the help of MAX and min ARGUMENT. If not provided, the DEFAULT range will be between 0 and 1.

60.

______ suspends the execution of a function wherever it is called and puts the function in debug mode.(a) debug()(b) trace()(c) recover()(d) browser()This question was addressed to me in homework.My doubt stems from Debugging Tools topic in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct CHOICE is (d) BROWSER()

To elaborate: The debug() FUNCTION initiates an INTERACTIVE debugger (also known as the “browser” in R) for a function.

61.

_______________ returns TRUE then X can be termed as a matrix data object.(a) is.”matrix(X”)(b) is.matrix(X)(c) is.notamatrix(X )(d) is.matrix(“X”)I have been asked this question in unit test.I'd like to ask this question from Functions in section Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer» RIGHT OPTION is (B) is.matrix(X)

For explanation: The FUNCTION CALL is.matrix(X ) returns TRUE then X can be termed as a matrix data object. R has a large number of in-built functions and also the user can create their own functions.
62.

Point out the wrong statement?(a) The order of the packages on the search list does not matter(b) R has separate namespaces for functions and non-functions(c) Users can configure which packages get loaded on startup so if you are writing a function(d) The search list can be found by using the search() functionThis question was addressed to me in unit test.I need to ask this question from Scoping Rules in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct CHOICE is (a) The order of the PACKAGES on the search list does not matter

For explanation I would say: The order of the packages on the search list matters, particularly if there are MULTIPLE objects with the same NAME in different packages.

63.

_______ allows you to modify the error behavior so that you can browse the function call stack(a) debug()(b) trace()(c) recover()(d) traceback()The question was asked during an online exam.This question is from Debugging Tools topic in chapter Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct answer is (c) RECOVER()

EXPLANATION: The recover() function can be used to modify the ERROR behavior of R when an error occurs.

64.

_________ is an indication that a fatal problem has occurred and execution of the function stops.(a) message(b) error(c) warning(d) message & warningThe question was asked in an online interview.My question is based upon Dates and Times topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Right option is (B) error

The EXPLANATION: ERRORS are produced by the STOP() FUNCTION.

65.

Which function basically finds the intersection between two different sets of data?(a) Converge(b) Merge(c) Delegate(d) SwapI have been asked this question in exam.This interesting question is from Functions topic in chapter Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The CORRECT option is (B) Merge

The explanation is: Merge () function is USED to combine TWO data frames and it identifies common ROWS or columns between the 2 data frames. Merge () function basically finds the intersection between two different sets of data.

66.

_________ variables are categorical variables which can hold either string or numeric values.(a) Factor(b) Simpler(c) Function(d) PackageI have been asked this question in an online quiz.This interesting question is from Functions in section Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct answer is (a) Factor

The explanation is: Factor variables are categorical variables that hold the string or numeric values. Factor variables are USED in various TYPES of graphics and particularly for statistical MODELLING where a correct NUMBER of degrees of freedom is assigned to them.

67.

How is a Data object represented internally in R language?(a) unclass (as.time (“2018-12-28″))(b) unclass (as.dat (“2018-12-28″))(c) unclass (as.D (2018-12-28))(d) unclass (as.Date (“2018-12-28″))I had been asked this question during an internship interview.This interesting question is from Functions in section Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct ANSWER is (d) unclass (as.Date (“2018-12-28″))

Explanation: unclass returns (a COPY of) its argument with its class information REMOVED. Unclass with an object is to remove from a class or CATEGORY.

68.

What will be the output of log (-5.8) when executed on R console?(a) NAN(b) NA(c) Error(d) 0.213This question was addressed to me in an internship interview.I want to ask this question from Functions in section Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Right choice is (a) NAN

Explanation: EXECUTING the above on R console or terminal will display a WARNING SIGN that NaN (Not a NUMBER)will be PRODUCED in R console because it is not possible to take a log of a negative number(-).

69.

The line of code in R language should begin with a ________________(a) Hash symbol(b) Alphabet(c) Number(d) CharacterThis question was addressed to me in an interview for job.My enquiry is from Functions in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer» RIGHT answer is (a) HASH symbol

Explanation: The LINE of code in R LANGUAGE should begin with a hash symbol (#). R has a large number of in-built functions and also the USER can create their own functions.
70.

You can check to see whether an R object is NULL with the _________ function.(a) is.null()(b) is.nullobj()(c) null()(d) as.nullobj()I got this question in homework.The origin of the question is Functions topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer» RIGHT answer is (a) is.null()

To elaborate: It is SOMETIMES useful to allow an argument to take the NULL VALUE, which might INDICATE that the function should take some SPECIFIC action.
71.

A programmer builds a _________ to avoid repeating the same task or reduce complexity.(a) Function(b) Package(c) Code(d) ConsoleThe question was posed to me during an internship interview.The doubt is from Functions topic in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct choice is (a) Function

Easy explanation: A function, in a programming environment, is a set of INSTRUCTIONS. A programmer builds a function to AVOID repeating the same TASK or reduce complexity. A function should be written to CARRY out specified tasks and may or may not include ARGUMENTS.

72.

Which function calculates the count of each category of a categorical variable?(a) Table(b) Intact(c) Tables(d) RetabsThe question was asked in an interview for job.Origin of the question is Functions topic in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct option is (a) Table

To explain: The frequency distribution of a CATEGORICAL variable can be checked using the table function in the R LANGUAGE. Table () function calculates the COUNT of each category of a categorical variable.

73.

If two vectors with different lengths perform some operation, the elements of the shorter vector will be used again to complete the operation. This is referred to as _________________(a) Element Recycling(b) Recycling(c) Cycling(d) Element CyclingThis question was posed to me during an internship interview.My enquiry is from Functions in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer» CORRECT choice is (a) Element Recycling

For explanation: If two vectors with different lengths perform an OPERATION, the elements of the shorter VECTOR will be used again to complete the operation. This is REFERRED to as element recycling.
74.

_________ package provides basic functionalities in R environment like arithmetic calculations, input/output.(a) R base(b) R boost(c) R serve(d) R commThis question was posed to me by my college professor while I was bunking the class.The doubt is from Functions topic in chapter Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct CHOICE is (a) R base

Explanation: R Base package is the package that is LOADED by default WHENEVER the R programming environment is loaded .R base package provides basic functionalities in R environment like arithmetic calculations, input/output.

75.

______________ function will measure the probability of the binary response variable in R language.(a) Glm()(b) Glmi()(c) Gelmi()(d) Jlm()I had been asked this question in homework.I need to ask this question from Functions topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The CORRECT choice is (a) Glm()

Easy explanation: Glm () in R language PROVIDES this functionality. Logistic regression is a statistical method for analysing a DATASET in which there are ONE or more independent VARIABLES that determine an outcome.

76.

_________ require you to pass a function whose argument is a vector of parameters.(a) optimize()(b) optimise()(c) opt()(d) opm()I had been asked this question in final exam.This intriguing question comes from Scoping Rules in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Right OPTION is (c) opt()

EASY EXPLANATION: Optimization routines in R like optim(), nlm(), and optimize() require you to pass a FUNCTION.

77.

___________ function is used to apply an expression for a given dataset.(a) This()(b) With()(c) Unwith()(d) That()I had been asked this question during an interview for a job.My doubt is from Functions in section Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct answer is (b) With()

For explanation: With a () function is used to apply an EXPRESSION for a given dataset. R language has a LARGE number of in-built FUNCTIONS and the USER can create their own functions. In R, a function is an object to the R interpreter is able to pass control to the function.

78.

Point out the correct statement?(a) R has a number of ways to indicate to you that something’s not right(b) Executing any function in R may result in the condition(c) “condition” is a generic concept for indicating that something unexpected has occurred(d) All of the mentionedI had been asked this question during an interview.This intriguing question originated from Dates and Times topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct CHOICE is (d) All of the mentioned

For explanation I would say: PROGRAMMERS can CREATE their own CUSTOM conditions if they WANT.

79.

What is the memory limit in R for 64 bit system?(a) 8 TB(b) 9TB(c) 10TB(d) 16TBThe question was posed to me in a national level competition.This is a very interesting question from Functions topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer» RIGHT choice is (a) 8 TB

Easy explanation: 8TB is the memory LIMIT for 64-bit system memory and 3GB is the limit for 32-bit system memory. A solid understanding of R’s memory management will help you predict how much memory you’ll need for a given task.
80.

__________ is the easiest method for reshaping the data before analysis.(a) Transpose()(b) Structure()(c) Package(d) FunctionThis question was posed to me during an interview for a job.Enquiry is from Functions in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct choice is (a) TRANSPOSE()

To explain I would say: Transpose t () is the easiest method for reshaping the DATA before analysis. The transpose (reversing rows and columns) is always the simplest method of reshaping a DATASET. Use the t() function to transpose a MATRIX or a data frame.

81.

What is the command used to store R objects in a file?(a) save (x, file=”x.Rdata”)(b) save (x, file=x.Rdata)(c) save (x, file=”x.Rdata”);(d) save (x, file=”x.data”)I got this question in class test.I need to ask this question from Functions topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct option is (a) save (x, file=”x.Rdata”)

EXPLANATION: The function save() can be used to save ONE or more R objects to a specified file (in .RData or .rda type file formats). The function can be read BACK from the file using the function load(). Note that if you save your data with save(), it cannot be restored under a different name.

82.

________ functions can be “built which contain all of the necessary data for evaluating the function.(a) Objective(b) reflective(c) Nested(d) SymmetryI got this question in unit test.I would like to ask this question from Scoping Rules topic in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Right option is (a) Objective

Easiest explanation: However, an objective FUNCTION that needs to be minimized MIGHT depend on a HOST of other THINGS besides its parameters.

83.

____________ function can be used to select the random sample of size ‘n’ from a huge dataset.(a) Simple()(b) Sample()(c) While()(d) Signal()The question was posed to me by my school principal while I was bunking the class.I want to ask this question from Functions topic in chapter Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct ANSWER is (b) Sample()

Best EXPLANATION: Sample () function can be used to select a random sample of size ‘n’ from the huge DATASET. R has a large number of in-built FUNCTIONS and also the user can create their own functions.

84.

________ function generates “n” normal random numbers based on the mean and standard deviation arguments passed to the function.(a) rnorm(b) vnorm(c) knorm(d) lnormThe question was asked in unit test.This question is from Functions topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct option is (a) RNORM

For explanation: rnorm function generates “n” NORMAL random numbers based on the mean and standard deviation arguments passed to the function. The WORKSPACE of R is FLEXIBLE to all FUNCTIONS of statistics.

85.

Which package can be integrated with dplyr for large fast tables?(a) Table(b) Data, dplyr(c) Data.table(d) Dplyr.tableThe question was posed to me during an interview.This is a very interesting question from Functions topic in section Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct option is (C) Data.table

The best I can explain: Data.table PACKAGE can be INTEGRATED with dplyr for large fast tables. dplyr package is used to speed up data frame management code. dplyr is a package for data MANIPULATION, written and maintained REGULARLY by Hadley Wickham.

86.

To get the current date, the _______ function will return a Date object which can be converted to a different class if necessary.(a) Sys.Time(b) Sys.Date(c) Sys.DateTime(d) DateTimeThis question was posed to me by my college director while I was bunking the class.I want to ask this question from Dates and Times topic in chapter Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct option is (B) Sys.Date

Explanation: The POSIXlt class stores date/time values as a list of components (HOUR, MIN, sec, mon, etc.) making it easy to extract these PARTS.

87.

___________ function gives an error message if the desired package cannot be loaded.(a) Dplyr(b) Require(c) Library(d) SampleThis question was posed to me in an internship interview.My question is based upon Functions topic in section Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct answer is (C) Library

To explain: Library () function gives an error message if the DESIRED package cannot be loaded. Require () function is USUALLY used inside a function and THROWS a warning whenever a PARTICULAR package is not found.

88.

________ allows you to insert debugging code into a function a specific places(a) debug()(b) trace()(c) browser()(d) traceback()I have been asked this question in class test.The origin of the question is Debugging Tools topic in chapter Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer» CORRECT choice is (b) trace()

EASIEST explanation: The FUNCTION call stack is the SEQUENCE of functions that was called before the error occurred.
89.

Which function helps you perform sorting in R language?(a) Order(b) Inorder(c) Simple(d) LibraryThe question was posed to me by my school teacher while I was bunking the class.This interesting question is from Functions topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

Correct answer is (a) Order

Explanation: Order RETURNS a permutation which rearranges its first ARGUMENT into ascending and also descending order. The result of the order COMMAND is a vector where each value references to the VALUES of the position of the object in the original data FRAME.

90.

A ________________ in R programming language can also contain numeric and alphabets along with special characters like dot and underline.(a) Variable name(b) Number(c) Integer(d) CharacterThis question was addressed to me during an interview for a job.My question is from Functions topic in division Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct choice is (a) Variable NAME

To explain I would SAY: A variable name in R programming language can ALSO contain numeric and alphabets along with special characters like a DOT and underline. Variable names in R language can begin with an alphabet and also the dot symbol.

91.

What are the data types in R on which binary operators can be applied?(a) Scalars(b) Matrices(c) Vectors(d) Scalars, Matrices and VectorsThe question was posed to me during a job interview.I want to ask this question from Functions topic in portion Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The correct answer is (d) SCALARS, Matrices and Vectors

Easiest explanation: R has a large NUMBER of in-built functions and the USER can create their own functions. In R, a function is an object. So the R interpreter is able to pass control to the function.

92.

___________ can be used for storing the data for long-term.(a) HDLS(b) HDFS(c) HDLSV(d) HSSLVThis question was addressed to me in an interview for internship.My question comes from Functions topic in chapter Control Structures, Functions, Scoping Rules, Loop Functions and Debugging of R Programming

Answer»

The CORRECT answer is (b) HDFS

To EXPLAIN I would say: The Hadoop DISTRIBUTED File System (HDFS) is the primary data storage system used in Hadoop applications. The Hadoop Distributed File System ( HDFS ) is a distributed file system designed for a RUN on COMMODITY hardware.