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.

________ function is similar to the existing subset() function in R but is quite a bit faster.(a) rename(b) filter(c) set(d) subsetI got this question in an interview.The query is from dplyr topic in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct CHOICE is (b) filter

Easy explanation: The filter() function is used to EXTRACT SUBSETS of ROWS from a data FRAME.

2.

The dplyr package can be installed from GitHub using the _______ package.(a) dev(b) devtools(c) devtool(d) devdelI got this question during an interview.My question is taken from dplyr in division R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct CHOICE is (b) devtools

To EXPLAIN: The GitHub REPOSITORY will usually contain the LATEST updates to the package and the DEVELOPMENT version.

3.

.rda extension used when saving data with function __________(a) save()(b) save.image()(c) save and save.image functions(d) serialize()The question was asked in an online quiz.This question is from Textual Data Formats topic in division R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct choice is (c) SAVE and save.image functions

The EXPLANATION is: Save is used for saving an ARBITRARY number of R objects with a binary format (possibly COMPRESSED) to a file. The output of dput() can also be SAVED directly to a file. Save.Image can be used mostly in R.

4.

Which of the following function gives the day of the week?(a) weekdays(b) months(c) quarters(d) semestersI had been asked this question in final exam.The query is from Vectorized Operations topic in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right answer is (a) weekdays

The explanation is: Weekdays will give the DAY of the week. months function give the month NAME. Quarters divide the YEAR into fourths. SEMESTERS divide the year into halfs.

5.

Point out the correct statement?(a) You can also omit variables using the select() function by using the negative sign(b) The arrange() function also allows a special syntax that allows you to specify variable names based on patterns(c) Reordering rows of a data frame is normally easier to do in R(d) The dplyr package provides any “new” functionality to RThis question was posed to me in an online quiz.Asked question is from dplyr in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct choice is (a) You can also omit variables using the SELECT() function by using the NEGATIVE sign

To explain I would say: The ARRANGE() function is used to reorder ROWS of a data frame ACCORDING to one of the variables/columns.

6.

If we want to save individual R objects to a file, we use the _______ function.(a) save()(b) save.image()(c) serialize()(d) deserialize()I got this question during a job interview.The query is from Textual Data Formats in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right ANSWER is (a) SAVE()

The explanation is: Save is used for saving an ARBITRARY number of R objects with a binary format (possibly COMPRESSED) to a file. The output of dput() can also be saved directly to a file.

7.

dput() output is in the form of ___________(a) R code(b) text file code(c) binary code(d) both binary and textThis question was posed to me by my school teacher while I was bunking the class.I'm obligated to ask this question of Textual Data Formats in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right OPTION is (a) R code

To explain I would say: DPUT is used for outputting a textual representation of an R object. The dump() and dput() functions are useful because the resulting textual format is editable, and in the case of CORRUPTION, POTENTIALLY recoverable.

8.

One way to pass data around is by de parsing the R object with _________(a) dput()(b) write()(c) read()(d) dget()This question was addressed to me during an interview for a job.I want to ask this question from Textual Data Formats in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct option is (a) dput()

For explanation I would SAY: dput is used for OUTPUTTING a textual representation of an R object. The DUMP() and dput() FUNCTIONS are useful because the resulting textual format is editable, and in the CASE of corruption, potentially recoverable.

9.

load() is used for _______(a) reading(b) loading(c) working(d) not existI got this question during an online exam.My doubt is from Textual Data Formats in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct answer is (a) reading

Easiest EXPLANATION: Load is used for reading in saved workspaces. After installing the package it is important that you load it into your R session with the library() FUNCTION. you can load the DATA into R USING the readRDS() function.

10.

The _________ function is used to generate summary statistics from the data frame within strata defined by a variable.(a) groupby()(b) group()(c) group_by()(d) arrangeThis question was posed to me in a national level competition.The origin of the question is dplyr topic in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct option is (c) group_by()

Easiest explanation: The general operation here is a combination of splitting a data frame into separate pieces defined by a variable or GROUP of variables (group_by()), and then applying a SUMMARY function ACROSS those SUBSETS (summarize()).

11.

Connections to text files can be created with the ________ function.(a) url(b) gzfile(c) bzfile(d) fileI got this question during an interview.My question is based upon Connection Interfaces topic in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Correct OPTION is (d) FILE

Best EXPLANATION: The file() function has a number of arguments that are common to MANY other connection functions.

12.

The _________ function can be used to select columns of a data frame that you want to focus on.(a) select(b) rename(c) get(d) setI had been asked this question in an interview.My question is taken from dplyr in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer» RIGHT option is (a) select

To elaborate: The select() FUNCTION allows you to get the few columns you MIGHT need.
13.

Which of the following return a subset of the columns of a data frame?(a) select(b) retrieve(c) get(d) setThis question was addressed to me in quiz.My question is based upon dplyr in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct option is (a) select

The EXPLANATION: ONE important contribution of the dplyr package is that it provides a “grammar” for data MANIPULATION and for operating on data FRAMES.

14.

If you have a lot of objects that you want to save to a file, we use ________ function.(a) save()(b) save.image()(c) serialize()(d) deserialize()This question was addressed to me in exam.My question is based upon Textual Data Formats topic in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer» RIGHT CHOICE is (b) save.image()

To explain: Save is used for saving an ARBITRARY number of R OBJECTS with a binary format (possibly compressed) to a file. The output of DPUT() can also be saved directly to a file. Save.Image can be used mostly in R.
15.

Point out the correct statement?(a) The data frame is a key data structure in statistics and in R(b) R has an internal implementation of data frames that is likely the one you will use most often(c) There are packages on CRAN that implement data frames via things like relational databases that allow you to operate on very very large data frames(d) All of the mentionedThe question was posed to me in an interview.I need to ask this question from dplyr in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right option is (d) All of the mentioned

Explanation: The BASIC STRUCTURE of a data frame is that there is one OBSERVATION per row and each column represents a variable, a MEASURE, feature, or CHARACTERISTIC of that observation.

16.

The ______ operator allows you to string operations in a left-to-right fashion.(a) %>%>(b) %>%(c) >%>%(d) >>>>%%%I got this question in quiz.I want to ask this question from dplyr topic in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct OPTION is (B) %>%

For EXPLANATION I WOULD say: The pipeline operator %>% is very handy for stringing together multiple dplyr functions in a sequence of operations.

17.

The benefit of the _____ function is that it is the only way to perfectly repressed an R object in an exportable format, without losing precision or any metadata.(a) save()(b) save.image()(c) unserialize()(d) serialize()The question was posed to me during an online exam.This intriguing question originated from Textual Data Formats in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right answer is (d) serialize()

Explanation: Unserialize is used for READING single R objects in the BINARY form. Serialize is used for converting an R object into a binary format for outputting to a CONNECTION (or FILE).

18.

When you call serialize() on an R object, the output will be ____ coded in hexadecimal format.(a) raw vector(b) character vector(c) integer vector(d) binary vectorI had been asked this question during a job interview.I want to ask this question from Textual Data Formats in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right answer is (a) raw VECTOR

Easy explanation: When you CALL serialize() on an R object, the OUTPUT will be raw vector coded in hexadecimal format. Serialize is used for converting an R object into a BINARY format for outputting to a connection.

19.

We can dump() R objects to a file by passing _____(a) character vector of their names(b) object name(c) arguments(d) file nameThe question was asked in an online quiz.My doubt stems from Textual Data Formats in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct answer is (a) character vector of their names

Explanation: Dump is used for dumping a TEXTUAL representation of multiple R objects. Descriptive representation of an R object by using the DPUT() or dump() functions. The dump() and dput() functions are USEFUL because the resulting textual format is editable, and in the case of corruption, POTENTIALLY RECOVERABLE.

20.

Unlike writing out a table or CSV file, dump() and dput() preserve the ______ so that another user doesn’t have to specify the all over again.(a) metadata(b) backup data(c) attribute data(d) normal dataThis question was addressed to me in semester exam.I'd like to ask this question from Textual Data Formats in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct answer is (a) metadata

Explanation: The read.table() function is one of the most commonly used functions for reading DATA. The help file with read.table() is worth reading in its ENTIRETY if only because the function GETS used a LOT.

21.

Columns can be arranged in descending order too by using the special ____ operator.(a) asc()(b) desc()(c) descending()(d) subsetI have been asked this question in an interview.This intriguing question comes from dplyr in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Correct answer is (b) DESC()

To elaborate: This will SORT the ORDER in decreasing order.

22.

________ opens a connection to a file compressed with gzip.(a) url(b) gzfile(c) bzfile(d) fileThe question was asked in examination.Enquiry is from Connection Interfaces in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The CORRECT answer is (B) gzfile

For explanation I WOULD say: “FILE” opens a CONNECTION to a file.

23.

Point out the correct statement?(a) The complement to the textual format is the binary format(b) If you have a lot of objects that you want to save to a file, you can save all objects in your workspace using the save.image() function(c) The serialize() function is used to convert individual R objects into a binary format that can be communicated across an arbitrary connection(d) All of the mentionedThe question was posed to me in an interview for job.This interesting question is from Connection Interfaces in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer» CORRECT choice is (d) All of the mentioned

The BEST explanation: It’s better to STICK with a BINARY FORMAT for efficiency and accuracy.
24.

Individual R objects can be saved to a file using the _____ function.(a) save(b) put(c) save_image(d) getI have been asked this question by my college director while I was bunking the class.The doubt is from Connection Interfaces in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right option is (a) SAVE

To elaborate: The key FUNCTIONS for CONVERTING R objects into a BINARY format are save(), save.image(), and serialize().

25.

dplyr can be integrated with the ________ package for large fast tables.(a) data.table(b) read.table(c) data.data(d) table.readThis question was addressed to me in an online interview.I want to ask this question from dplyr topic in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct answer is (a) data.table

The BEST I can EXPLAIN: The DPLYR package is handy WAY to both simplify and speed up your data frame management code.

26.

Point out the wrong statement?(a) Renaming a variable in a data frame in R is surprisingly hard to do(b) The mutate() function exists to compute transformations of variables in a data frame(c) mute() function, which does the same thing as mutate() but then drops all non-transformed variables(d) The data frame is a key data structure in statistics and in RThis question was addressed to me in semester exam.Asked question is from dplyr topic in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The CORRECT option is (c) mute() FUNCTION, which does the same thing as mutate() but then drops all non-transformed variables

Easy EXPLANATION: The rename() function is designed to make this process EASIER.

27.

Which of the following code opens a connection to the file foo.txt, reads from it, and closes the connection when its done?(a) data

Answer» RIGHT option is (a) data <- read.csv(“foo.txt”)

The best explanation: Connections MUST be OPENED, then the are read from or written to, and then they are closed.
28.

There is an SQL interface for relational databases via the _______ package.(a) DIB(b) DB2(c) DBI(d) DIB21I had been asked this question in semester exam.Question is taken from dplyr in division R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct choice is (C) DBI

The BEST I can EXPLAIN: dplyr can work with other data frame “backends” such as SQL databases.

29.

The dplyr package can be installed from CRAN using __________(a) installall.packages(“dplyr”)(b) install.packages(“dplyr”)(c) installed.packages(“dplyr”)(d) installed.packages(“dpl”)This question was addressed to me in class test.My question is from dplyr in division R – Data Storage, Formats, Objects and Operations of R Programming

Answer» CORRECT option is (b) install.packages(“DPLYR”)

EXPLANATION: After INSTALLING the PACKAGE it is important that you load it into your R session with the library() function.
30.

_________ generate summary statistics of different variables in the data frame, possibly within strata.(a) rename(b) summarize(c) set(d) subsetThe question was posed to me in exam.The question is from dplyr in division R – Data Storage, Formats, Objects and Operations of R Programming

Answer» RIGHT CHOICE is (b) summarize

The explanation is: The dplyr PACKAGE as a NUMBER of its own data TYPES that it takes advantage of.
31.

Multiple objects can be de parsed at once using the ______ function.(a) dput()(b) write()(c) dump()(d) dget()I got this question in homework.My question is based upon Textual Data Formats in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct option is (a) dput()

To ELABORATE: dput is used for outputting a TEXTUAL representation of an R object. The dump() and dput() FUNCTIONS are USEFUL because the resulting textual format is editable, and in the case of CORRUPTION, potentially recoverable.

32.

Multiple objects can be de parsed at once and read back using function _____(a) source()(b) read()(c) dget()(d) dput()I had been asked this question during an interview.The question is from Textual Data Formats topic in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right answer is (a) SOURCE()

EXPLANATION: MARTIN Machler made an important contribution by making Ross and ROBERT use the GNU General Public License to make R free software. This was CRITICAL because this allowed for the source code for the entire R system to be accessible to anyone who wanted to tinker with it.

33.

The _______ operator is used to connect multiple verb actions together into a pipeline.(a) pipe(b) piper(c) start(d) endThe question was posed to me in an interview for internship.My doubt stems from dplyr topic in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The CORRECT answer is (a) pipe

For explanation I WOULD say: It is DENOTED by %>% sign.

34.

Point out the correct statement?(a) Times use the POSIXct and POSIXlt class(b) Dates and times have special classes in R that allow for numerical and statistical calculations(c) Character strings can be coerced to Date/Time classes using the strptime function(d) All of the mentionedThe question was posed to me by my school principal while I was bunking the class.This interesting question is from Vectorized Operations topic in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Correct choice is (d) All of the mentioned

Easiest explanation: CHARACTER STRINGS can be coerced to Date/Time classes using the as.Date, as.POSIXlt, or as.POSIXct.

35.

Which of the following statement will load the objects to the file named “mydata.RData”?(a) save(“mydata.RData”)(b) load(“mydata.RData”)(c) loadAll(“mydata.RData”)(d) put(“mydata.RData”)I had been asked this question in exam.I'd like to ask this question from Connection Interfaces in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right answer is (B) load(“mydata.RData”)

For EXPLANATION I would say: .RDA and .RData are fairly common extensions and you may want to USE them because they are recognized by other SOFTWARE.

36.

.RData extension used when we save data using the functions ___________(a) save()(b) save.image()(c) save and save.image functions(d) serialize()I got this question in an international level competition.I want to ask this question from Textual Data Formats topic in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Correct ANSWER is (c) SAVE and save.image functions

Easiest EXPLANATION: Save is used for saving an arbitrary number of R objects with a binary format (possibly compressed) to a FILE. The output of dput() can also be saved DIRECTLY to a file. Save.Image can be used mostly in R.

37.

_________ extract a subset of rows from a dataframe based on logical conditions.(a) rename(b) filter(c) set(d) subsetI had been asked this question during an online exam.My question comes from dplyr topic in chapter R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Correct CHOICE is (a) rename

For explanation I would SAY: rename is USED to rename variables in a DATAFRAME.

38.

Point out the wrong statement?(a) The dplyr package was developed by Hadley Wickham of RStudio(b) The dplyr package is an optimized and distilled version of his plyr package(c) The dplyr package provides any “new” functionality to R(d) The dplyr package does not provide any “new” functionality to RThe question was asked in a national level competition.My query is from dplyr topic in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer» RIGHT option is (C) The dplyr package provides any “NEW” functionality to R

Best EXPLANATION: The dplyr package does not provide any “new” functionality to R.
39.

readlines is used for ____________(a) working on data(b) reading files(c) reading lines in files(d) not existThis question was posed to me in final exam.My question is based upon Textual Data Formats in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

The correct choice is (b) READING FILES

Explanation: ReadLines is USED for reading lines of a text FILE. you can LOAD the data into R using the readRDS() function. Text files can be read line by line using the readLines() function. This function is useful for reading text files that may be unstructured or contain non-standard data.

40.

Main way to read the data back in (parsing it) using the function.(a) dput()(b) write()(c) read()(d) dget()I got this question during an interview.Asked question is from Textual Data Formats topic in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Right OPTION is (d) dget()

Easy explanation: One WAY to pass data around is by deparsing the R object with dput() and reading it BACK in (parsing it) using dget(). dget is used for reading in R code FILES (INVERSE of dput).

41.

________ add new variables/columns or transform existing variables.(a) mutate(b) add(c) apped(d) arrangeThis question was addressed to me in an interview for job.This interesting question is from dplyr in section R – Data Storage, Formats, Objects and Operations of R Programming

Answer» CORRECT answer is (a) mutate

Easiest explanation: arrange is USED to REORDER ROWS of a dataframe.
42.

Point out the wrong statement?(a) When you call unserialize() on an R object, the output will be a raw vector coded in hexadecimal format(b) serialize() function is the only way to perfectly represent an R object in an exportable format(c) .rda extension is used when save() function is incorporated(d) The complement to the textual format is the binary formatI had been asked this question in an internship interview.This interesting question is from Connection Interfaces in portion R – Data Storage, Formats, Objects and Operations of R Programming

Answer»

Correct option is (a) When you call unserialize() on an R object, the output will be a RAW vector coded in hexadecimal format

Explanation: Output MAY GET sent to a file, but it COULD get sent over a network or other connection.

43.

Which of the following R code creates a connection to ‘foo.txt’?(a) con

Answer»

Correct option is (a) CON <- file(“foo.txt”)

Easy explanation: OPEN is USED for opening connection to ‘foo.txt’ in read-only MODE.