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.

1.

Using the ________ vector, we create a species factor and bind it to the columns of iris.df.(a) snames(b) rnames(c) jnames(d) fnamesThis question was addressed to me during an online exam.This interesting question is from Data Types topic in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right choice is (a) snames

Easy explanation: Using the Snames vector, we CREATE a species factor and BIND it to the COLUMNS of IRIS.df. The iris DATASET is a three dimensional dataset.

2.

___________ provides optional labels with the columns and rows.(a) Disnames(b) Dimnames(c) Denmes(d) DemnesdThis question was addressed to me during an online interview.I'd like to ask this question from Data Types topic in chapter Nuts and Bolts and Getting Data In and Out of R Programming

Answer» RIGHT answer is (b) Dimnames

The EXPLANATION is: byrow=TRUE indicates that the matrix should be filled by rows. byrow=FALSE indicates that the matrix should be filled by COLUMNS (the default). dimnames provides optional LABELS with the columns and rows.
3.

Which is the basic data structure of R containing the same type of data?(a) Functions(b) Array(c) Vector(d) ListsThis question was addressed to me by my school teacher while I was bunking the class.Asked question is from Data Types in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct answer is (c) Vector

To explain I would say: Vector is a BASIC DATA structure in R that contains an ELEMENT of similar type. These data types in R can be logical, integer, DOUBLE, character, complex and ALSO raw. In R using the function, typeof() one can check the data type of vector.

4.

The length of a list is ______ to the number of components in that list.(a) Double(b) Equal(c) Triple(d) One fourthThe question was asked in final exam.My enquiry is from Data Types in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct answer is (b) Equal

The explanation is: The length of a list is equal to the number of components in that list. Lists can be created using the list function. Like data FRAMES, they can INCORPORATE a MIXTURE of modes into the one list and each COMPONENT can be of a different length or size.

5.

Lists can be created using the _______ function.(a) Matrix.li(b) Matrix.lists(c) Lists.matric(d) ListI got this question in unit test.My doubt is from Data Types in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right ANSWER is (d) List

The explanation is: Lists can be created using the list FUNCTION. Like data frames, they can INCORPORATE a mixture of modes into the one list and each component can be of a DIFFERENT length or size.

6.

The ________ function creates a regular sequence of values to form a vector.(a) sequel(b) Rep(c) seq(d) GrepThis question was posed to me in examination.My question is based upon Data Types in chapter Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The CORRECT choice is (c) seq

The best I can explain: The rep function replicates elements of vectors. The seq function creates a regular sequence of values to FORM a vector. The FOUR most frequently used types of DATA objects in R are vectors, matrices, data FRAMES and lists.

7.

The data type of the R-object becomes the data type of the ________(a) Functions(b) Packages(c) Variables(d) ListsThis question was posed to me in an internship interview.I want to ask this question from Data Types in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right answer is (c) Variables

The best I can explain: In R, the variables are not declared as some DATA type. The variables are ASSIGNED with R-Objects and the data type of the R-object will become the data type of the VARIABLE. There are many TYPES of R-objects.

8.

Which of the following can be considered as object attribute?(a) dimensions(b) class(c) length(d) all of the mentionedThe question was asked during a job interview.This intriguing question comes from Data Types in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer» CORRECT OPTION is (d) all of the mentioned

To EXPLAIN: All objects in R have an Attribute list.
9.

Data frames can have additional attributes such as __________(a) Rowname()(b) Rownames()(c) R.names()(d) D.names()This question was addressed to me at a job interview.I want to ask this question from Data Types topic in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right option is (B) Rownames()

To explain I WOULD say: Data frames can have additional attributes such as rownames(), which can be useful for annotating data, like subject_id or sample_id. But most of the time they are not used. A data FRAME is an IMPORTANT data type in R.

10.

To extract a sublist, we use _________ brackets.(a) Flower(b) Square(c) Double(d) SingleThis question was posed to me during an interview for a job.My question is from Data Types in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right OPTION is (d) Single

To explain I WOULD say: To extract a SUBLIST, we use single BRACKETS. There are a number of ways of ACCESSING the first component of a list.

11.

Which function replicates elements of vectors?(a) C(b) Rep(c) Crep(d) GrepI have been asked this question in examination.I'd like to ask this question from Data Types topic in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct choice is (b) Rep

Explanation: The rep FUNCTION replicates ELEMENTS of VECTORS. The seq function creates a regular sequence of values to form a vector. The FOUR most frequently used types of data objects in R are vectors, matrices, data frames and lists.

12.

By what function we can create data frames?(a) Data.frames()(b) Data.sets ()(c) Function ()(d) C ()The question was asked in a national level competition.Enquiry is from Data Types topic in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct answer is (a) Data.frames()

The best explanation: Data frames are tabular data OBJECTS. Unlike a matrix in each data frame every COLUMN will contain different modes of data. Data Frames are CREATED using the data.frame() FUNCTION. It is the list of VECTORS of same length.

13.

A data frame is a special type of list where every element of the list has ______ length.(a) Same(b) Different(c) May be different(d) May be sameI had been asked this question by my college professor while I was bunking the class.My doubt is from Data Types topic in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct answer is (a) Same

The best EXPLANATION: A data FRAME is a very important data type in R. It’s pretty much the de facto data structure for most TABULAR data and what we use for statistics. A data frame was a special type of list in which every element of the list has the same length.

14.

Which are indexed by either row or column using a specific name or number?(a) Datasets(b) Data frames(c) Data(d) FunctionsThe question was asked in an internship interview.I'd like to ask this question from Data Types in chapter Nuts and Bolts and Getting Data In and Out of R Programming

Answer» CORRECT answer is (B) Data frames

To explain: Data frames can be INDEXED by either row or column using a SPECIFIC NAME (that corresponds to either the row or column) or a number.
15.

What is the simplest way of creating the vector?(a) C function(b) Create(c) Destroy(d) InvalidThe question was posed to me during a job interview.I want to ask this question from Data Types in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer» RIGHT option is (a) C FUNCTION

To explain: The simplest way to create a vector is through the concatenation function, c. This function BINDS elements TOGETHER, whether they are of character FORM, numeric or logical.
16.

Which dimension corresponds to the explanatory variables collected for each species?(a) First(b) Second(c) Third(d) FifthThe question was asked in unit test.This interesting question is from Data Types topic in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct CHOICE is (b) Second

For EXPLANATION I would say: The second dimension corresponds to the EXPLANATORY VARIABLES collected for each species. The THIRD dimension corresponds to the species.

17.

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.(a) Vector(b) Matrix(c) Lists(d) Data framesThis question was addressed to me during an interview.My question is taken from Data Types topic in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct option is (B) Matrix

To EXPLAIN I would say: A matrix 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.

18.

Which function takes a dim attribute which creates the required number of dimensions?(a) Vector(b) Array(c) Matrix(d) ListsI have been asked this question at a job interview.This interesting question is from Data Types in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct OPTION is (b) Array

Easy explanation: The array function takes a dim attribute which CREATES the REQUIRED number of dimensions. While matrices are confined to TWO dimensions, arrays COULD be of any number of dimensions.

19.

All columns in a matrix must have the same mode and the _________ length.(a) Different(b) Same(c) May be the same(d) May be differentThe question was asked in an internship interview.My query is from Data Types topic in chapter Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct option is (b) Same

Easiest EXPLANATION: All columns in a matrix must have the same mode(numeric, character, etc) and ALSO the same LENGTH. byrow=TRUE INDICATES that the matrix should be FILLED by rows. byrow=FALSE indicates that the matrix should be filled by columns (the default).

20.

R has how many atomic classes of objects?(a) 1(b) 2(c) 3(d) 5I got this question in an interview for job.This question is from Data Types in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right ANSWER is (d) 5

For EXPLANATION: The most BASIC TYPE of R OBJECT is a vector.

21.

The first component can be accessed using __________ operator.(a) Intraction(b) Extraction(c) AND(d) ORThis question was posed to me by my college professor while I was bunking the class.The question is from Data Types in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct choice is (B) Extraction

The best I can explain: There are a number of ways of accessing the first component of a list. We can either access it through the NAME of that component (if names are assigned) or by using a number corresponding to the position the component CORRESPONDS to. The former APPROACH can be performed using subsetting ([[]]) or alternatively, by the extraction operator ($).

22.

In R using the function, ________ one can check the data type of vector.(a) Typeof()(b) Castof()(c) Function()(d) C()I had been asked this question in unit test.Question is taken from Data Types in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right choice is (a) Typeof()

BEST explanation: In R using the function, typeof() one can check the data type of vector. Vector is a basic data structure in R which contains element of similar type. These data TYPES in R can be LOGICAL, integer, double, character, complex and also RAW.

23.

On what basis of a variable, OS allocates memory and decides what can be stored in the reserved memory?(a) Data bases(b) Data sets(c) Data types(d) ListsThis question was addressed to me in a national level competition.My enquiry is from Data Types topic in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct OPTION is (c) Data types

To elaborate: Based on the data type of a VARIABLE, the OS ALLOCATES the memory and decides what can be STORED on the reserved memory. This means that when you create a variable you RESERVE some space in memory.

24.

Numbers in R are generally treated as _______ precision real numbers.(a) single(b) double(c) real(d) imaginaryThe question was posed to me in class test.This interesting question is from Data Types topic in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right answer is (b) double

For explanation I WOULD say: This means that EVEN if you see a number like “1” or “2” in R, which you might THINK of as integers, they are likely REPRESENTED behind the scenes as numeric objects something like “1.00” or “2.00”.

25.

First component of the list can be accessed by _____________(a) Name of the component(b) List name(c) Function(d) PackageI had been asked this question in a national level competition.My query is from Data Types in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct OPTION is (a) Name of the component

Best explanation: There are a number of ways of ACCESSING the first component of a list. We can EITHER ACCESS it through the name of that component (if names are ASSIGNED) or by using a number corresponding to the position of the component.

26.

Which function is used to enter in data at the terminal?(a) Scanned(b) Scnn(c) Scan(d) SccnI have been asked this question in an interview for job.The origin of the question is Data Types topic in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct option is (c) Scan

The explanation: The scan FUNCTION is used to enter data at the terminal. This is USEFUL for small datasets but TIRESOME for entering in large datasets.

27.

The four most frequently used types of data objects in Rare vectors, matrices, data frames and ________(a) Function(b) Lists(c) Packages(d) InterfacesThis question was addressed to me at a job interview.Asked question is from Data Types topic in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct ANSWER is (b) Lists

The explanation: The four most FREQUENTLY used types of data OBJECTS in R are vectors, MATRICES, data frames and lists. A list is a generalisation of a vector and REPRESENTS a collection of data objects.

28.

Which is more general than a matrix, in that different columns can have different modes?(a) Data types(b) Data frames(c) Data sets(d) DatabasesI had been asked this question in an interview for internship.This intriguing question originated from Data Types topic in chapter Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct answer is (c) DATA sets

Easy explanation: A data frame is more general than a MATRIX, in that different columns can have different modes (numeric, character, factor, etc). This is similar to SAS and SPSS DATASETS. There are many WAYS to identify the elements of a data frame.

29.

Which function gives the list as output?(a) Spline(b) Matrix(c) Vector(d) AlphabetI have been asked this question during an online interview.This key question is from Data Types in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The CORRECT answer is (a) SPLINE

The best explanation: There are also many FUNCTIONS within R that produce a list as output. Examples of these functions INCLUDE spline(), density() and locator().Joining two lists can be achieved either using the concatenation FUNCTION or the append function.

30.

Which function can be used to determine the names assigned to a list?(a) Names(b) Name(c) Nam(d) NemThe question was posed to me in an online quiz.My doubt is from Data Types topic in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct choice is (a) Names

The explanation: To determine the names ASSIGNED to a list, the names function can be USED. Lists can be created USING the list function. Like DATA frames, they can incorporate a MIXTURE of modes into the one list and each component can be of a different length or size.

31.

Density function gives output as ________(a) Matrix(b) Lists(c) Vector(d) NumberThis question was posed to me by my college professor while I was bunking the class.My question is from Data Types topic in chapter Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct option is (b) Lists

The EXPLANATION: There are also MANY functions WITHIN R that produce a LIST as output. Examples of these functions include spline(), DENSITY() and locator().

32.

An ordered factor is used to represent an __________(a) Ordinal variable(b) Simple variable(c) Coordinal variable(d) Biordinal variableThe question was posed to me in examination.The origin of the question is Data Types topic in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right choice is (a) Ordinal VARIABLE

To elaborate: An ordered factor is used to REPRESENT an ordinal variable. R will treat factors as nominal variables and also ordered factors as ordinal variables in STATISTICAL procedures and GRAPHICAL analyses.

33.

If you explicitly want an integer, you need to specify the _____ suffix.(a) D(b) R(c) L(d) KI have been asked this question during an online interview.Question is from Data Types topic in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct choice is (c) L

To ELABORATE: Entering 1 in R GIVES you a NUMERIC object; entering 1L EXPLICITLY gives you an integer object.

34.

How can we access the first component of the list?(a) Number of the position(b) Function(c) Package(d) ToolsThe question was asked in an interview for job.My question is taken from Data Types topic in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right option is (a) Number of the position

For EXPLANATION I would say: There are a number of ways of accessing the first component of a list. We can either access it through the NAME of that component (if NAMES are assigned) or by USING a number corresponding to the position the component.

35.

Accessing elements is achieved through a process called ________(a) Indexing(b) Outdexing(c) Highlighting(d) ScrappingThe question was posed to me by my school principal while I was bunking the class.This key question is from Data Types topic in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer» CORRECT CHOICE is (a) Indexing

To ELABORATE: Accessing elements is achieved through a process called indexing. Indexing may be done by a VECTOR of positive integers and negative integers to indicate inclusion.
36.

Which of the following is a 3-dimensional dataset?(a) Eris(b) Iris(c) Toris(d) IrisThe question was posed to me in class test.My doubt stems from Data Types in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right answer is (B) Iris

To ELABORATE: The iris DATASET is a three dimensional dataset. ONE dimension is represented for each species: Setosa, Versicolor and Virginica.

37.

Decimal values are referred as ________ data types in R.(a) Numeric(b) Character(c) Integer(d) ListsThe question was posed to me in class test.My enquiry is from Data Types in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct choice is (a) Numeric

To explain: Decimal VALUES are REFERRED to as numeric data types in R. Data frames are the tabular data objects. Unlike a matrix in data FRAME every COLUMN can contain different MODES of data.

38.

Attributes of an object (if any) can be accessed using the ______ function.(a) objects()(b) attrib()(c) attributes()(d) obj()This question was addressed to me during an interview.The doubt is from Data Types topic in chapter Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct CHOICE is (C) attributes()

Explanation: Not all R objects CONTAIN attributes, in which case the attributes() function RETURNS NULL.

39.

vectors can be one of two types namely atomic vectors and _______(a) Matrix(b) Vector(c) Lists(d) ArrayI had been asked this question in exam.This is a very interesting question from Data Types topic in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct option is (c) Lists

Explanation: A vector is the most common and basic data STRUCTURE in R. Technically, vectors can be ONE of TWO TYPES of atomic vectors and lists. Although vector most commonly refers to the atomic types.

40.

Point out the correct statement?(a) Empty vectors can be created with the vector() function(b) A sequence is represented as a vector but can contain objects of different classes(c) “raw” objectsare commonly used directly in data analysis(d) The value NaN represents undefined valueThis question was posed to me in quiz.This interesting question is from Data Types topic in chapter Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right ANSWER is (a) EMPTY vectors can be created with the VECTOR() function

Explanation: A vector can only CONTAIN objects of the same class.

41.

Computation with vectors is achieved using an element-by-element operation for avoiding _________(a) Loops(b) Functions(c) Packages(d) InterfacesI had been asked this question in my homework.I'm obligated to ask this question of Data Types topic in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct choice is (a) Loops

Easiest explanation: COMPUTATION with vectors is ACHIEVED using an element-by-element operation. This is useful when writing CODE because it AVOIDS ’for loops’.

42.

Factors are the r-objects which are created using a _________(a) Vector(b) Matrix(c) Lists(d) ArrayThis question was addressed to me in an interview for internship.Question is taken from Data Types in chapter Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct OPTION is (a) Vector

Explanation: Factors are the r-objects which are CREATED using a vector. It stores the vector with ALSO the distinct values of the elements in the vector as labels. They are USEFUL in statistical modelling.

43.

The _________ function returns a list of densities (y) corresponding to bin values (x).(a) Spline(b) Density(c) Lists(d) LocatorI had been asked this question in homework.My question is from Data Types topic in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct CHOICE is (a) Spline

The explanation: The spline function returns a list of densities (y) CORRESPONDING to bin values (x). These can be PASSED to the PLOT routine to PRODUCE a line graph of the density.

44.

Joining two lists can be achieved either using the _________ function.(a) Concat(b) Join(c) Reduce(d) DeleteThe question was posed to me in a national level competition.My query is from Data Types in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct CHOICE is (a) Concat

The best I can EXPLAIN: JOINING two lists can be achieved EITHER using the concatenation function or the APPEND function.

45.

________ are similar to matrices but can have more than two dimensions.(a) Functions(b) Packages(c) Arrays(d) ColumnsI had been asked this question during a job interview.My doubt stems from Data Types topic in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct CHOICE is (c) ARRAYS

Explanation: Arrays are similar to matrices which can have more than two dimensions. See help(array) for details. FACTORS are created using the factor() function. We can Identify ELEMENTS of a list using the [[]] convention.

46.

Point out the correct statement?(a) The value NaN represents undefined value(b) Number Inf represents infinity in R(c) NaN can also be thought of as a missing value(d) “raw” objectsare commonly used directly in data analysisI got this question by my school teacher while I was bunking the class.This is a very interesting question from Data Types in section Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Right answer is (b) NUMBER INF represents infinity in R

The EXPLANATION: This allows us to represent entities like 1 / 0.

47.

A _________ is a two-dimensional rectangular data set.(a) Vector(b) Lists(c) Matrix(d) FunctionsI had been asked this question in an internship interview.This interesting question is from Data Types topic in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct choice is (c) Matrix

For explanation I would say: A matrix is a two-dimensional rectangular DATA set. It can be CREATED USING the vector input to a matrix function. The labels are always character irrespective of whether it is numeric or character and also BOOLEAN etc in the vector.

48.

What should we use to access elements with a value greater than five?(a) Subsetting commands(b) Use functions(c) Packages(d) InterfacesThis question was addressed to me at a job interview.Query is from Data Types topic in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct choice is (a) Subsetting COMMANDS

Best EXPLANATION: To access elements with a value greater than FIVE we can USE some subsetting commands and logical OPERATORS to produce the desired result.

49.

Factors are created using the _______ function.(a) C()(b) Function()(c) Array()(d) Lists()I got this question during an internship interview.The origin of the question is Data Types in portion Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

The correct option is (B) Function()

Best explanation: Factors are created using the factor() function. The labels are always CHARACTER irrespective of WHETHER it is numeric or character or also Boolean etc. in the vector. The nlevels functions will give the COUNT of levels.

50.

R objects can have attributes, which are like ________ for the object.(a) metadata(b) features(c) expression(d) dimensionsThe question was posed to me in an internship interview.I want to ask this question from Data Types in division Nuts and Bolts and Getting Data In and Out of R Programming

Answer»

Correct option is (a) METADATA

The EXPLANATION is: These metadata can be very useful in that they HELP to DESCRIBE the object.