3- R Programming main file
3- R Programming main file
Answer: a
Clarification: Anybody is free to download and install these packages and even inspect the source
code. The instructions for obtaining R largely depend on the user’s hardware and operating system.
2. How to install for a package and all of the other packages on which for depends?
a) install.packages (for, depends = TRUE)
b) R.install.packages (“for”, depends = TRUE)
c) install.packages (“for”, depends = TRUE)
d) install (“for”, depends = FALSE)
Answer: c
Clarification: To install a package named for, open up R and type install.packages(“for”). To install
foo and additionally install all of the other packages on which for depends, instead type
install.packages (“for”, depends = TRUE).
Answer: d
Clarification: Type library() at the command prompt to see a list of all available packages in the
library. For total information about the installation of R and add-on packages, see the R Installation
and Administration manual.
Answer: c
Clarification: The longer programs called scripts, there is too much code to write all at once at the
command prompt. Furthermore, for longer scripts, it is convenient to be able to only modify a
certain piece of the script and run it again in R.
5. Scripts will run on ___________________
a) Script Editors
b) Console
c) Terminal
d) GCC Compiler
Answer: a
Clarification: script editors are designed to aid the communication and code writing process. They
have all sorts of features including R syntax highlighting, automatic code completion, delimiter
matching, and dynamic help on the R functions.
Answer: d
Clarification: “Recommended” packages also include boot, class, cluster, codetools, foreign,
KernSmooth, lattice, mgcv, nlme, rpart, survival, MASS, nnet, Matrix. There are about ten thousand
packages in R now.
Answer: b
Clarification: GUI elements are usually accessed through a device. All programs running a GUI use a
consistent set of graphical elements so that once the user learns a particular interface.
Answer: a
Clarification: R Commander provides a point-and-click interface to statistical problems. It is called
the “Commander” because every time one makes a selection, the code corresponding to the task is
listed in the output window.
options(digits = 16)
20/6
a) 3.33
b) 3.333
c) 3.3333333
d) 3.3333333333333333
Answer: d
Clarification: We know that 20/6 is a repeating decimal, We can change the number of digits
displayed with options. This will make the number after the decimal point to extend for the required
amount.
Answer: a
Clarification: An IDE tailored to the needs of interactive data analysis and statistical programming
called R studio. In R studio we can directly interact with R through the inbuilt functions and
packages. We can also download new packages.
Answer: a
Clarification: Compared to other programming languages, the R community tends to be more
focussed on results instead of processes. Knowledge of software engineering best practice.
Answer: d
Clarification: You are confronted with over 20 years of evolution every time you use R. Learning R
can be hard because there are many special cases in R to remember. R is the best user of memory.
Answer: a
Clarification: RStudio is very popular with a nice interface and well thought out, especially for more
advanced usage. It can be a bit buggy, so make sure you update it regularly. Available on all
platforms.
Answer: d
Clarification: The expression a <- 16 creates a variable called a and gives it the value 16 called
assignment. The variable on the left is assigned to the value on the right. The left side should have
only a single one.
16. In the expression x <- 4 in R, what is the class of ‘x’ as determined by the `class()’ function?
a) Character
b) Numeric
c) Integer
d) Word
Answer: c
Clarification: In R, there is an extension of the numeric or character vectors. They are not a separate
type of object but simply an atomic vector with dimensions.
Answer: b
Clarification: There are base packages (which come with R automatically), and contributed packages.
The base packages are maintained by a select group of volunteers, called R Core. In addition to the
base packages, there are over ten thousand additional contributed packages written by individuals
all over the world.
x + y
a) Symbol
b) Missing Data
c) 5
d) 15.5
Answer: b
Clarification: Missing data are a persistent and prevalent problem in many statistical analyses,
especially those associated with the social sciences. R reserves the special symbol NA to represent
missing data. Ordinary arithmetic with NA value gives NA’s (addition, subtraction, etc.) and applying
a function to a vector that has a NA in it will usually give a NA.
Answer: a
Clarification: The R language is a dialect of S which was designed in the 1980s. Since the early 90’s
the life of the S language has gone down a rather winding path. The scoping rules for R are the main
feature that makes it different from the original S language.
Answer: a
Clarification: The language syntax has a superficial similarity with C, but the semantics are of the FPL
(functional programming language) variety with stronger affinities with Lisp and APL. There are many
syntaxes in C, which are closely resembled with R.
a) Numeric
b) Character
c) Integer
d) Logical
Answer: b
Clarification: All three elements can be expressed as a character. Both paste() and cat() will printout
text to the console by combining multiple character vectors together. The original data are
formatted as character strings so we convert them to R’s Date format for easier manipulation.
a) 4
b) 5
c) 6
d) 0
Answer: c
Clarification: Length of b [1] 2 3 4 5 6 7 is 6. We can also create an empty list of a prespecified length
with the vector() function. Data frames are represented as a special type of list where every element
of the list has to have the same length.
a) Numeric
b) Character
c) Integer
d) Logical
Answer: a
Clarification: All the elements in ‘b’ can be expressed in numeric. Both paste() and cat() will printout
text to the console by combining multiple character vectors together. The original data are
formatted as character strings so we convert them to R’s Data format for easier manipulation.
a) Numeric, Integer
b) Integer, Numeric
c) Integer, Integer
d) Numeric, Numeric
Answer: b
Clarification: Here typeof() tells about the data type. They are an important type of object in R and
are used in a variety of statistical modelling applications. You can determine an object’s type with
the typeof function.
10. What is the function to set row names for a data frame?
a) row.names()
b) colnames()
c) col.names()
d) column name cannot be set for a data frame
Answer: a
Clarification: row.names() is the function to set row names for a data frame. Data frames have a
special attribute called row.names, which indicate information about each row of the data frame.
Answer: a
Clarification: Single element of a character vector is often referred to as a character string. Dates are
represented by the Date class and can be coerced from a character string using the as.Date()
function. This is a common way to end up with a Date object in R.
Answer: a
Clarification: All R files have an extension .R. R provides a mechanism for recalling and re-executing
previous commands. All S programmed files will have an extension .S. But R has many functions than
S.
3. If the code is stored in the external file, which of the following function is used to call them to a
working directory?
a) exec()
b) source()
c) execute()
d) sourcefile()
Answer: b
Clarification: source is available in the file menu. Today R runs on almost any standard computing
platform and operating system. Its open source nature. The copyright for the primary source code
for R is held by the R Foundation and is published under the GNU General Public License version.
Answer: c
Clarification: C, C++ and Fortran can be linked. There are a number of people had used something
like C/C++ programming languages to manipulate the R objects.
Answer: c
Clarification: TIBCO is the current owner of the S language. In 2008, Insightful was acquired by TIBCO
for $25 million. As of this writing, TIBCO is the current owner of the S language and is its exclusive
developer.
Answer: a
Clarification: CRAN hosts many add-on packages that can extend the functionality of R. Connections
allow R functions to talk to all different external objects without having to write custom code for
each object.
7. Dataframes can be converted into a matrix by calling the following function data ______
a) matr()
b) matrix()
c) matrixf()
d) matrixfunc()
Answer: b
Clarification: as.matrix function should be used to coerce a data frame to a matrix. It might seem
that the as.matrix() function should be used to coerce a data frame to a matrix.
a) a b
b) “a” “b”
c) 1 1
d) Error
Answer: d
Clarification: It is not possible to coerce, so you will get a Warning. Logical creates a logical vector of
the specified length. Each element of the vector is equal to FALSE. as.logical attempts to coerce its
argument to be of a logical type.
mode(a)
a) Character
b) Numeric
c) Complex
d) Integer
Answer: a
Clarification: Mode of the given command is a character. There are a complementary function
writeLines() that takes a character vector and writes each element of the vector one line at a time to
a text file.
Answer: c
Clarification: Calls, expressions and names are the three types of objects that constitute the R
language. There is really only one rule about vectors in R, which is that A vector can only contain
objects of the same class. R objects can have names, which is very useful for writing readable code
and self-describing objects.
x + y
a) Symbol
b) Missing Data
c) 5
d) 15.5
Answer: b
Clarification: Missing data are a persistent and prevalent problem in many statistical analyses,
especially those associated with the social sciences. R reserves the special symbol NA to represent
missing data. Ordinary arithmetic with NA value gives NA’s (addition, subtraction, etc.) and applying
a function to a vector that has a NA in it will usually give a NA.
Answer: a
Clarification: The R language is a dialect of S which was designed in the 1980s. Since the early 90’s
the life of the S language has gone down a rather winding path. The scoping rules for R are the main
feature that makes it different from the original S language.
Answer: a
Clarification: The language syntax has a superficial similarity with C, but the semantics are of the FPL
(functional programming language) variety with stronger affinities with Lisp and APL. There are many
syntaxes in C, which are closely resembled with R.
Answer: b
Clarification: All three elements can be expressed as a character. Both paste() and cat() will printout
text to the console by combining multiple character vectors together. The original data are
formatted as character strings so we convert them to R’s Date format for easier manipulation.
a) 4
b) 5
c) 6
d) 0
Answer: c
Clarification: Length of b [1] 2 3 4 5 6 7 is 6. We can also create an empty list of a prespecified length
with the vector() function. Data frames are represented as a special type of list where every element
of the list has to have the same length.
a) Numeric
b) Character
c) Integer
d) Logical
Answer: a
Clarification: All the elements in ‘b’ can be expressed in numeric. Both paste() and cat() will printout
text to the console by combining multiple character vectors together. The original data are
formatted as character strings so we convert them to R’s Data format for easier manipulation.
a) Numeric, Integer
b) Integer, Numeric
c) Integer, Integer
d) Numeric, Numeric
Answer: b
Clarification: Here typeof() tells about the data type. They are an important type of object in R and
are used in a variety of statistical modelling applications. You can determine an object’s type with
the typeof function.
Answer: b
Clarification: R language has 6 atomic data types. They are logical, integer, real, complex, string (or
character) and raw. There is also a class for “raw” objects, but they are not commonly used directly
in data analysis.
10. What is the function to set row names for a data frame?
a) row.names()
b) colnames()
c) col.names()
d) column name cannot be set for a data frame
Answer: a
Clarification: row.names() is the function to set row names for a data frame. Data frames have a
special attribute called row.names, which indicate information about each row of the data frame.
Answer: a
Clarification: Single element of a character vector is often referred to as a character string. Dates are
represented by the Date class and can be coerced from a character string using the as.Date()
function. This is a common way to end up with a Date object in R.
Answer: a
Clarification: All R files have an extension .R. R provides a mechanism for recalling and re-executing
previous commands. All S programmed files will have an extension .S. But R has many functions than
S.
3. If the code is stored in the external file, which of the following function is used to call them to a
working directory?
a) exec()
b) source()
c) execute()
d) sourcefile()
Answer: b
Clarification: source is available in the file menu. Today R runs on almost any standard computing
platform and operating system. Its open source nature. The copyright for the primary source code
for R is held by the R Foundation and is published under the GNU General Public License version.
Answer: c
Clarification: C, C++ and Fortran can be linked. There are a number of people had used something
like C/C++ programming languages to manipulate the R objects.
Answer: c
Clarification: TIBCO is the current owner of the S language. In 2008, Insightful was acquired by TIBCO
for $25 million. As of this writing, TIBCO is the current owner of the S language and is its exclusive
developer.
Answer: a
Clarification: CRAN hosts many add-on packages that can extend the functionality of R. Connections
allow R functions to talk to all different external objects without having to write custom code for
each object.
7. Dataframes can be converted into a matrix by calling the following function data ______
a) matr()
b) matrix()
c) matrixf()
d) matrixfunc()
Answer: b
Clarification: as.matrix function should be used to coerce a data frame to a matrix. It might seem
that the as.matrix() function should be used to coerce a data frame to a matrix.
8. What will be the output of the following R code?
as.logical(x)
a) a b
b) “a” “b”
c) 1 1
d) Error
Answer: d
Clarification: It is not possible to coerce, so you will get a Warning. Logical creates a logical vector of
the specified length. Each element of the vector is equal to FALSE. as.logical attempts to coerce its
argument to be of a logical type.
mode(a)
a) Character
b) Numeric
c) Complex
d) Integer
Answer: a
Clarification: Mode of the given command is a character. There are a complementary function
writeLines() that takes a character vector and writes each element of the vector one line at a time to
a text file.
Answer: c
Clarification: Calls, expressions and names are the three types of objects that constitute the R
language. There is really only one rule about vectors in R, which is that A vector can only contain
objects of the same class. R objects can have names, which is very useful for writing readable code
and self-describing objects.
Answer: b
Clarification: There are base packages (which come with R automatically), and contributed packages.
The base packages are maintained by a select group of volunteers, called R Core. In addition to the
base packages, there are over ten thousand additional contributed packages written by individuals
all over the world.
x + y
a) Symbol
b) Missing Data
c) 5
d) 15.5
Answer: b
Clarification: Missing data are a persistent and prevalent problem in many statistical analyses,
especially those associated with the social sciences. R reserves the special symbol NA to represent
missing data. Ordinary arithmetic with NA value gives NA’s (addition, subtraction, etc.) and applying
a function to a vector that has a NA in it will usually give a NA.
Answer: a
Clarification: The R language is a dialect of S which was designed in the 1980s. Since the early 90’s
the life of the S language has gone down a rather winding path. The scoping rules for R are the main
feature that makes it different from the original S language.
Answer: a
Clarification: The language syntax has a superficial similarity with C, but the semantics are of the FPL
(functional programming language) variety with stronger affinities with Lisp and APL. There are many
syntaxes in C, which are closely resembled with R.
5. What is the mode of ‘a’ in the following R code?
a) Numeric
b) Character
c) Integer
d) Logical
Answer: b
Clarification: All three elements can be expressed as a character. Both paste() and cat() will printout
text to the console by combining multiple character vectors together. The original data are
formatted as character strings so we convert them to R’s Date format for easier manipulation.
a) 4
b) 5
c) 6
d) 0
Answer: c
Clarification: Length of b [1] 2 3 4 5 6 7 is 6. We can also create an empty list of a prespecified length
with the vector() function. Data frames are represented as a special type of list where every element
of the list has to have the same length.
a) Numeric
b) Character
c) Integer
d) Logical
Answer: a
Clarification: All the elements in ‘b’ can be expressed in numeric. Both paste() and cat() will printout
text to the console by combining multiple character vectors together. The original data are
formatted as character strings so we convert them to R’s Data format for easier manipulation.
a) Numeric, Integer
b) Integer, Numeric
c) Integer, Integer
d) Numeric, Numeric
Answer: b
Clarification: Here typeof() tells about the data type. They are an important type of object in R and
are used in a variety of statistical modelling applications. You can determine an object’s type with
the typeof function.
9. How many atomic vector types does R have?
a) 5
b) 6
c) 8
d) 10
Answer: b
Clarification: R language has 6 atomic data types. They are logical, integer, real, complex, string (or
character) and raw. There is also a class for “raw” objects, but they are not commonly used directly
in data analysis.
10. What is the function to set row names for a data frame?
a) row.names()
b) colnames()
c) col.names()
d) column name cannot be set for a data frame
Answer: a
Clarification: row.names() is the function to set row names for a data frame. Data frames have a
special attribute called row.names, which indicate information about each row of the data frame.
Answer: a
Clarification: Anybody is free to download and install these packages and even inspect the source
code. The instructions for obtaining R largely depend on the user’s hardware and operating system.
2. How to install for a package and all of the other packages on which for depends?
a) install.packages (for, depends = TRUE)
b) R.install.packages (“for”, depends = TRUE)
c) install.packages (“for”, depends = TRUE)
d) install (“for”, depends = FALSE)
Answer: c
Clarification: To install a package named for, open up R and type install.packages(“for”). To install
foo and additionally install all of the other packages on which for depends, instead type
install.packages (“for”, depends = TRUE).
Answer: d
Clarification: Type library() at the command prompt to see a list of all available packages in the
library. For total information about the installation of R and add-on packages, see the R Installation
and Administration manual.
Answer: c
Clarification: The longer programs called scripts, there is too much code to write all at once at the
command prompt. Furthermore, for longer scripts, it is convenient to be able to only modify a
certain piece of the script and run it again in R.
Answer: a
Clarification: script editors are designed to aid the communication and code writing process. They
have all sorts of features including R syntax highlighting, automatic code completion, delimiter
matching, and dynamic help on the R functions.
Answer: d
Clarification: “Recommended” packages also include boot, class, cluster, codetools, foreign,
KernSmooth, lattice, mgcv, nlme, rpart, survival, MASS, nnet, Matrix. There are about ten thousand
packages in R now.
Answer: a
Clarification: R Commander provides a point-and-click interface to statistical problems. It is called
the “Commander” because every time one makes a selection, the code corresponding to the task is
listed in the output window.
options(digits = 16)
20/6
a) 3.33
b) 3.333
c) 3.3333333
d) 3.3333333333333333
Answer: d
Clarification: We know that 20/6 is a repeating decimal, We can change the number of digits
displayed with options. This will make the number after the decimal point to extend for the required
amount.
Answer: a
Clarification: An IDE tailored to the needs of interactive data analysis and statistical programming
called R studio. In R studio we can directly interact with R through the inbuilt functions and
packages. We can also download new packages.
Answer: d
Clarification: You are confronted with over 20 years of evolution every time you use R. Learning R
can be hard because there are many special cases in R to remember. R is the best user of memory.
Answer: d
Clarification: Statistics for relatively advanced users. R has thousands of packages, designed,
maintained, and widely used by statisticians. We can code ourselves if a command is not present.
Answer: a
Clarification: RStudio is very popular with a nice interface and well thought out, especially for more
advanced usage. It can be a bit buggy, so make sure you update it regularly. Available on all
platforms.
Answer: d
Clarification: The expression a <- 16 creates a variable called a and gives it the value 16 called
assignment. The variable on the left is assigned to the value on the right. The left side should have
only a single one.
16. In the expression x <- 4 in R, what is the class of ‘x’ as determined by the `class()’ function?
a) Character
b) Numeric
c) Integer
d) Word
Answer: c
Clarification: In R, there is an extension of the numeric or character vectors. They are not a separate
type of object but simply an atomic vector with dimensions.
Answer: b
Clarification: There are base packages (which come with R automatically), and contributed packages.
The base packages are maintained by a select group of volunteers, called R Core. In addition to the
base packages, there are over ten thousand additional contributed packages written by individuals
all over the world.
x + y
a) Symbol
b) Missing Data
c) 5
d) 15.5
Answer: b
Clarification: Missing data are a persistent and prevalent problem in many statistical analyses,
especially those associated with the social sciences. R reserves the special symbol NA to represent
missing data. Ordinary arithmetic with NA value gives NA’s (addition, subtraction, etc.) and applying
a function to a vector that has a NA in it will usually give a NA.
Answer: a
Clarification: The language syntax has a superficial similarity with C, but the semantics are of the FPL
(functional programming language) variety with stronger affinities with Lisp and APL. There are many
syntaxes in C, which are closely resembled with R.
a) Numeric
b) Character
c) Integer
d) Logical
Answer: b
Clarification: All three elements can be expressed as a character. Both paste() and cat() will printout
text to the console by combining multiple character vectors together. The original data are
formatted as character strings so we convert them to R’s Date format for easier manipulation.
a) 4
b) 5
c) 6
d) 0
Answer: c
Clarification: Length of b [1] 2 3 4 5 6 7 is 6. We can also create an empty list of a prespecified length
with the vector() function. Data frames are represented as a special type of list where every element
of the list has to have the same length.
a) Numeric
b) Character
c) Integer
d) Logical
Answer: a
Clarification: All the elements in ‘b’ can be expressed in numeric. Both paste() and cat() will printout
text to the console by combining multiple character vectors together. The original data are
formatted as character strings so we convert them to R’s Data format for easier manipulation.
a) Numeric, Integer
b) Integer, Numeric
c) Integer, Integer
d) Numeric, Numeric
Answer: b
Clarification: Here typeof() tells about the data type. They are an important type of object in R and
are used in a variety of statistical modelling applications. You can determine an object’s type with
the typeof function.
Answer: b
Clarification: R language has 6 atomic data types. They are logical, integer, real, complex, string (or
character) and raw. There is also a class for “raw” objects, but they are not commonly used directly
in data analysis.
10. What is the function to set row names for a data frame?
a) row.names()
b) colnames()
c) col.names()
d) column name cannot be set for a data frame
Answer: a
Clarification: row.names() is the function to set row names for a data frame. Data frames have a
special attribute called row.names, which indicate information about each row of the data frame.
Answer: a
Clarification: All R files have an extension .R. R provides a mechanism for recalling and re-executing
previous commands. All S programmed files will have an extension .S. But R has many functions than
S.
3. If the code is stored in the external file, which of the following function is used to call them to a
working directory?
a) exec()
b) source()
c) execute()
d) sourcefile()
Answer: b
Clarification: source is available in the file menu. Today R runs on almost any standard computing
platform and operating system. Its open source nature. The copyright for the primary source code
for R is held by the R Foundation and is published under the GNU General Public License version.
Answer: c
Clarification: C, C++ and Fortran can be linked. There are a number of people had used something
like C/C++ programming languages to manipulate the R objects.
Answer: c
Clarification: TIBCO is the current owner of the S language. In 2008, Insightful was acquired by TIBCO
for $25 million. As of this writing, TIBCO is the current owner of the S language and is its exclusive
developer.
6. Functionality of R is divided into a number of __________
a) Functions
b) Domains
c) Packages
d) Files
Answer: a
Clarification: CRAN hosts many add-on packages that can extend the functionality of R. Connections
allow R functions to talk to all different external objects without having to write custom code for
each object.
7. Dataframes can be converted into a matrix by calling the following function data ______
a) matr()
b) matrix()
c) matrixf()
d) matrixfunc()
Answer: b
Clarification: as.matrix function should be used to coerce a data frame to a matrix. It might seem
that the as.matrix() function should be used to coerce a data frame to a matrix.
as.logical(x)
a) a b
b) “a” “b”
c) 1 1
d) Error
Answer: d
Clarification: It is not possible to coerce, so you will get a Warning. Logical creates a logical vector of
the specified length. Each element of the vector is equal to FALSE. as.logical attempts to coerce its
argument to be of a logical type.
mode(a)
a) Character
b) Numeric
c) Complex
d) Integer
Answer: a
Clarification: Mode of the given command is a character. There are a complementary function
writeLines() that takes a character vector and writes each element of the vector one line at a time to
a text file.
Answer: c
Clarification: Calls, expressions and names are the three types of objects that constitute the R
language. There is really only one rule about vectors in R, which is that A vector can only contain
objects of the same class. R objects can have names, which is very useful for writing readable code
and self-describing objects.
a) Numeric
b) Character
c) Integer
d) Logical
Answer: a
Clarification: The labels are always character irrespective of whether it is numeric or character and
also Boolean etc. on the input vector. The nlevels functions will give the count of levels. Factors are
created using the factor() function.
2. 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 different
Answer: b
Clarification: 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).
4. ________ are similar to matrices but can have more than two dimensions.
a) Functions
b) Packages
c) Arrays
d) Columns
Answer: c
Clarification: 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.
5. 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) Databases
Answer: c
Clarification: 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.
Answer: d
Clarification: An ordered collection of objects are called lists. A list allows you to gather a variety of
(possibly unrelated) objects under one name. We can Identify elements of a list using the [[]]
convention.
7. The ________ stores the nominal values as a vector of integers in the range of 1 to unique values
in the nominal variable.
a) Factor
b) Matrix
c) Lists
d) Functions
Answer: a
Clarification: The factor stores the nominal values as a vector of integers in the range [1… k] (where k
is the no. of unique values of the nominal variable), and an internal vector of character strings (the
original values) mapped to these integers.
8. An ordered factor is used to represent an __________
a) Ordinal variable
b) Simple variable
c) Coordinal variable
d) Biordinal variable
Answer: a
Clarification: 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.
9. 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) Lists
Answer: c
Clarification: 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.
10. The data type of the R-object becomes the data type of the ________
a) Functions
b) Packages
c) Variables
d) Lists
Answer: c
Clarification: 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.
Answer: a
Clarification: When you want to create a vector with more than one element, you should use c()
function which means to combine the elements into a vector. We can Identify elements of a list
using the [[]] convention.
2. A __________ is an R-object which can contain many different types of elements inside it.
a) Vector
b) Lists
c) Matrix
d) Functions
Answer: b
Clarification: A list is an R-object which can contain many different types of elements in it like
vectors, functions and even another list inside it. We can Identify elements of a list using the [[]]
convention.
Answer: c
Clarification: 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.
4. Which function takes a dim attribute which creates the required number of dimensions?
a) Vector
b) Array
c) Matrix
d) Lists
Answer: b
Clarification: 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.
Answer: a
Clarification: 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.
Answer: a
Clarification: 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.
8. vectors can be one of two types namely atomic vectors and _______
a) Matrix
b) Vector
c) Lists
d) Array
Answer: c
Clarification: 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.
Answer: a
Clarification: Lists are sometimes called generic vectors because the elements of a list can be of any
type of R object, even lists containing further lists. This property makes them fundamentally
different from other atomic vectors. Create lists using list() and coerce other objects using as.list().
10. 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 same
Answer: a
Clarification: 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.
11. Data frames can have additional attributes such as __________
a) Rowname()
b) Rownames()
c) R.names()
d) D.names()
Answer: b
Clarification: 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.
Answer: a
Clarification: 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.
13. Which is the basic data structure of R containing the same type of data?
a) Functions
b) Array
c) Vector
d) Lists
Answer: c
Clarification: 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.
14. In R using the function, ________ one can check the data type of vector.
a) Typeof()
b) Castof()
c) Function()
d) C()
Answer: a
Clarification: 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.
15. __________are Data frames which contain lists of homogeneous data in a tabular format.
a) Matrix
b) Vector
c) Lists
d) Array
Answer: c
Clarification: Matrices are Data frames which contain lists of homogeneous data in a tabular format.
Technically, vectors can be one of two types of atomic vectors and lists. Although vector is mostly
refers to the atomic types.
A. Ross Ihaka
B. Robert Gentleman
C. Both A and B
D. Ross Gentleman
View Answer
Ans : C
Explanation: R was created by Ross Ihaka and Robert Gentleman at the University of Auckland, New
Zealand, and is currently developed by the R Development Core Team.
A. C
B. Ruby
C. Java
D. Basic
View Answer
Ans : A
Explanation: R allows integration with the procedures written in the C, C++, .Net, Python or
FORTRAN languages for efficiency.
3. R is free software distributed under a GNU-style copy left, and an official part of the GNU project
called?
A. GNU A
B. GNU S
C. GNU L
D. GNU R
View Answer
Ans : B
Explanation: R is free software distributed under a GNU-style copy left, and an official part of the
GNU project called GNU S.
A. 1992
B. 1995
C. 1993
D. 1994
View Answer
Ans : C
View Answer
6. Point out the wrong statement?
View Answer
Ans : B
7. Command lines entered at the console are limited to about ________ bytes
A. 4095
B. 4096
C. 4097
D. 4098
View Answer
Ans : A
Explanation: Elementary commands can be grouped together into one compound expression by
braces (‘{’ and ‘}’).
A. s
B. c
C. sas
D. matlab
View Answer
Ans : A
Explanation: The R language is a dialect of S which was designed in the 1980s. Since the early 90’s
the life of the S language has gone down a rather winding path. The scoping rules for R are the main
feature that makes it different from the original S language.
A. 3
B. 4
C. 5
D. 6
View Answer
Ans : D
Explanation: R language has 6 atomic data types. They are logical, integer, real, complex, string (or
character) and raw. There is also a class for “raw” objects, but they are not commonly used directly
in data analysis.
A. .S
B. .RP
C. .R
D. .SP
View Answer
Ans : C
Explanation: All R files have an extension .R. R provides a mechanism for recalling and re-executing
previous commands. All S programmed files will have an extension .S. But R has many functions than
S.
1. What will be output for the following code?
v <- TRUE
print(class(v))
A. logical
B. Numeric
C. Integer
D. Complex
View Answer
Ans : A
v <- ""TRUE""
print(class(v))
A. logical
B. Numeric
C. Integer
D. Character
View Answer
Ans : D
3. In R programming, the very basic data types are the R-objects called?
A. Lists
B. Matrices
C. Vectors
D. Arrays
View Answer
Ans : C
Explanation: In R programming, the very basic data types are the R-objects called vectors
A. frame() function
B. data.frame() function
C. data() function
D. frame.data() function
View Answer
A. level
B. levels
C. nlevels
D. nlevel
View Answer
Ans : C
Explanation: Factors are created using the factor() function. The nlevels functions gives the count of
levels.
View Answer
>x
A. 1 0
B. 0 0 0 0 0 0 0 0 0 0
C. 0 1
D. 0 0 1 1 0 1 1 0
View Answer
Ans : B
Explanation: You can also use the vector() function to initialize vectors.
> sqrt(-17)
A. -4.02
B. 4.02
C. 3.67
D. NAN
View Answer
Ans : D
Explanation: These metadata can be very useful in that they help to describe the object.
9. _______ function returns a vector of the same size as x with the elements arranged in increasing
order.
A. sort()
B. orderasc()
C. orderby()
D. sequence()
View Answer
Ans : A
Explanation: There are other more flexible sorting facilities available like order() or sort.list() which
produce a permutation to do the sorting.
> dim(m)
A. 3 3
B. 3 2
C. 2 3
D. 2 2
View Answer
Ans : C
Answer: Option A
Explanation:
D. None
Answer: Option B
Explanation:
A. matr()
B. mat()
C. matrix()
Explanation:
Answer: Option A
Explanation:
Column names and row names can be set separately using the colnames() and rownames()
functions.
Answer: Option C
Explanation:
The dimension attribute is itself an integer vector of length 2 (number of rows, number of columns).
6. What would be the output of the following code ?
x - vector("list", length = 5)
A. NULL
B. 1
C. 0
Answer: Option A
Explanation:
We can also create an empty list of a pre-specified length with the vector() function.
as.logical(x)
A. a b c
B. NA NA NA
C. 0 1 2
Answer: Option B
Explanation:
When nonsensical coercion takes place, you will usually get a warning from R.
8. What would be the output of the following code ?
m - matrix(nrow = 2, ncol = 3)
dim(m)
A. 3 2
B. 2 3
C. 2 2
Answer: Option B
Explanation:
sqrt(-17)
A. -4.02
B. 4.02
C. NaN
Answer: Option C
Explanation:
These metadata can be very useful in that they help to describe the object.
1. Which of the following is Mac menu command ?
A. browse.workspace
B. browse.works
C. browser.workspace
D. a statistical transformation
Answer: Option A
Explanation:
It is a Mac menu command that creates a window with information about all variables in the
workspace.
A. as.numeric(x)
B. as.integer(x)
C. as.order(x)
Answer: Option B
Explanation:
Compare to round(x,0) in R.
A. X %*% Y
B. solve(A)
C. solve(A,B)
D. All of the mentioned
Answer: Option C
Explanation:
A. str
B. forecast
C. stringr
Answer: Option C
Explanation:
A. install.pack(forecast")
B. install.packages(cast")
C. install.packages(forecast")
Answer: Option C
Explanation:
A. str
B. abc
C. zyz
Answer: Option B
Explanation:
The package implements several ABC algorithms for performing parameter estimation and model
selection.
7. Which of the following package contains functions for reading and displaying satellite data for
oceanographic applications with R ?
A. saves
B. satin
C. saws
Answer: Option B
Explanation:
A. Regression
B. Summarization
C. Clustering
D. Classification
Answer: Option D
Explanation:
A. factor.model
B. col.max(x)
C. stem
D. which.max(x)
Answer: Option A
Explanation:
Rajput
R language
View Answer
Ans : C
Explanation: R was created by Ross Ihaka and Robert Gentleman at the University of
Auckland, New Zealand, and is currently developed by the R Development Core Team.
View Answer
Ans : B
Explanation: R is free software distributed under a GNU-style copy left, and an official
part of the GNU project called GNU S.
View Answer
Ans : C
Explanation: R made its first appearance in 1993.
View Answer
Ans : D
Explanation: All of the above statement are true.
6. Point out the wrong statement?
A. Setting up a workstation to take full advantage of the customizable features
of R is a straightforward thing
B. q() is used to quit the R program
C. R has an inbuilt help facility similar to the man facility of UNIX
D. Windows versions of R have other optional help systems also
View Answer
Ans : B
Explanation: help command is used for knowing details of particular command in R.
View Answer
Ans : A
Explanation: Elementary commands can be grouped together into one compound
expression by braces (‘{’ and ‘}’).
View Answer
Ans : A
Explanation: The R language is a dialect of S which was designed in the 1980s. Since
the early 90’s the life of the S language has gone down a rather winding path. The
scoping rules for R are the main feature that makes it different from the original S
language.
View Answer
Ans : D
Explanation: R language has 6 atomic data types. They are logical, integer, real,
complex, string (or character) and raw. There is also a class for “raw” objects, but they
are not commonly used directly in data analysis.
View Answer
Ans : C
Explanation: All R files have an extension .R. R provides a mechanism for recalling and
re-executing previous commands. All S programmed files will have an extension .S. But
R has many functions than S.
print(class(v))
A. logical
B. Numeric
C. Integer
D. Complex
View Answer
Ans : A
Explanation: It produces the following result :
[1] ""logical""
2. What will be output for the following code?
v <- ""TRUE""
print(class(v))
A. logical
B. Numeric
C. Integer
D. Character
View Answer
Ans : D
Explanation: It produces the following result :
[1] ""character""
View Answer
Ans : C
Explanation: In R programming, the very basic data types are the R-objects
called vectors
View Answer
Ans : B
Explanation: Data Frames are created using the data.frame() function
View Answer
Ans : C
Explanation: Factors are created using the factor() function. The nlevels functions gives
the count of levels.
View Answer
Ans : A
Explanation: A vector can only contain objects of the same class.
> x
A. 1 0
B. 0 0 0 0 0 0 0 0 0 0
C. 0 1
D. 0 0 1 1 0 1 1 0
View Answer
Ans : B
Explanation: You can also use the vector() function to initialize vectors.
A. -4.02
B. 4.02
C. 3.67
D. NAN
View Answer
Ans : D
Explanation: These metadata can be very useful in that they help to describe the object.
View Answer
Ans : A
Explanation: There are other more flexible sorting facilities available like order() or
sort.list() which produce a permutation to do the sorting.
> dim(m)
A. 3 3
B. 3 2
C. 2 3
D. 2 2
View Answer
Ans : C
Explanation: Matrices are constructed column-wise.
View Answer
Ans : B
Explanation: for loop : Like a while statement, except that it tests the condition at the end
of the loop body.
View Answer
Ans : A
Explanation: The next statement simulates the behavior of R switch.
View Answer
Ans : C
Explanation: Break : Terminates the loop statement and transfers execution to the
statement immediately following the loop.
5. Point out the wrong statement?
A. Multi-line expressions with curly braces are just not that easy to sort through
when working on the command line
B. lappy() loops over a list, iterating over each element in that list
C. lapply() does not always returns a list
D. You cannot use lapply() to evaluate a function multiple times each with a
different argument
View Answer
Ans : C
Explanation: lapply() always returns a list, regardless of the class of the input.
View Answer
Ans : A
Explanation: True, The mapply() function is a multivariate apply of sorts which applies a
function in parallel over a set of arguments.
View Answer
Ans : B
Explanation: x is a vector (or list) or data frame
if (i == ""D"") {
next
print(i)
A. A
B. B
C. C
D. D
View Answer
Ans : D
Explanation: When the above code is compiled and executed, it produces the following
result :
[1] ""A""
[1] ""B""
[1] ""C""
[1] ""E""
[1] ""F""
for ( i in v) {
print(v)
A. A
B. A B
C. A B C
D. A B C D
View Answer
Ans : A
Explanation: The output for the following code : [1] ""A""
10. What will be output for the following code?
v <- LETTERS[""A""]
for ( i in v) {
print(v)
A. A
B. NAN
C. NA
D. Error
View Answer
Ans : C
Explanation: The output for the following code : [1] NA
View Answer
Ans : B
Explanation: An R function is created by using the keyword function.
A. 1526
B. 53.5
C. 50.5
D. 55
View Answer
Ans : B
Explanation: The code will find mean of numbers from 25 to 82 that is 53.5
View Answer
Ans : A
Explanation: Functions in R are “first class objects”, which means that they can be
treated much like any other R object.
A. a+b
B. a:b
C. a-b
D. None of the above
View Answer
Ans : D
Explanation: With the paste() function, the arguments sep and collapse must be named
explicitly and in full if the default values are not going to be used.
View Answer
Ans : C
Explanation: t.tests () function in R language is used to find out whether the means of 2
groups are equal to each other. It is not used most commonly in R. It is used in some
specific conditions.
View Answer
Ans : B
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(-).
View Answer
Ans : C
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().
View Answer
Ans : A
Explanation: It can be done using the match () function- match () function returns the first
appearance of a particular element. The other way is to use %in% which returns a
Boolean value either true or false.
9. 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()
View Answer
Ans : A
Explanation: It is sometimes useful to allow an argument to take the NULL value, which
might indicate that the function should take some specific action.
View Answer
Ans : D
Explanation: In the base graphics system, boxplot or text function is used to add
elements to a plot.
View Answer
Ans : C
Explanation: forecast is used for time series analysis
View Answer
Ans : B
Explanation: ddply splits a data frame and returns a data frame.
View Answer
Ans : B
Explanation: This package contains Classes and functions for genetic data analysis
within the multivariate framework.
View Answer
Ans : A
Explanation: This package contains a collection of functions that perform operations on
time-series accelerometer data, such as identify non-wear time, flag minutes that are
part of an activity about, and find the maximum 10-minute average count value.
View Answer
Ans : C
Explanation: The function returns a GriegSmith object which is a matrix with block sizes,
sum of squares for each block size as well as mean sums of squares. G1DBN is a
package performing Dynamic Bayesian Network Inference.
6. Which of the following package provide namespace management
functions not yet present in base R?
A. stringr
B. nbpMatching
C. messagewarning
D. namespace
View Answer
Ans : D
Explanation: The package namespace is one of the most confusing parts of building a
package. nbpMatching contains functions for non-bipartite optimal matching.
View Answer
Ans : B
Explanation: Make sure you have the latest version of R and then run the above code to
get the packages you’ll need. It installs the given packages. Confirm that you have a
recent version of RStudio.
View Answer
Ans : B
Explanation: A bundled package is a package that’s been compressed into a single file.
A source package is just a directory with components like R/, DESCRIPTION, and so on.
9. .library() is not useful when developing a package since you have to
install the package first.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: library() is not useful when developing a package since you have to install
the package first. A library is a simple directory containing installed packages.
View Answer
Ans : A
Explanation: DESCRIPTION uses a very simple file format called DCF, the Debian
control format. When you first start writing packages, you’ll mostly use these metadata to
record what packages are needed to run your package.
Answer: a
Explanation: Most classical statistics and much of the latest methodology is available for
use with R.
Answer: a
Explanation: When you use the R program it issues a prompt when it expects input
commands.
Answer: a
Explanation: At this point R commands may be issued.
advertisement
Answer: c
Explanation: R is an expression language with a very simple syntax.
?solve
a) help(solve)
b) print(solve)
c) bind(solve)
d) matrix(solve)
View Answer
Answer: a
Explanation: help is used to get more information on any specific named function.
Answer: c
Explanation: If an expression is given as a command, it is evaluated, printed (unless
specifically made invisible), and the value is lost.
8. If a command is not complete at the end of a line, R will give a different prompt, by default
it is ____________
a) *
b) –
c) +
d) /
View Answer
Answer: c
Explanation: Comments can be put almost anywhere, starting with a hashmark (‘#’),
everything to the end of the line is a comment.
9. Command lines entered at the console are limited to about ________ bytes.
a) 3000
b) 4095
c) 5000
d) 6000
View Answer
Answer: b
Explanation: Elementary commands can be grouped together into one compound
expression by braces (‘{’ and ‘}’).
10._____ text editor provides more general support mechanisms via ESS for working
interactively with R.
a) EAC
b) Emacs
c) Shell
d) ECAP
View Answer
Answer: b
Explanation: The recall and editing capabilities under UNIX are highly customizable.
Answer: b
Explanation: There are base packages (which come with R automatically), and
contributed packages. The base packages are maintained by a select group of volunteers,
called R Core. In addition to the base packages, there are over ten thousand additional
contributed packages written by individuals all over the world.
x + y
a) Symbol
b) Missing Data
c) 5
d) 15.5
View Answer
Answer: b
Explanation: Missing data are a persistent and prevalent problem in many statistical
analyses, especially those associated with the social sciences. R reserves the special
symbol NA to represent missing data. Ordinary arithmetic with NA value gives NA’s
(addition, subtraction, etc.) and applying a function to a vector that has a NA in it will
usually give a NA.
advertisement
Answer: a
Explanation: The R language is a dialect of S which was designed in the 1980s. Since the
early 90’s the life of the S language has gone down a rather winding path. The scoping
rules for R are the main feature that makes it different from the original S language.
Answer: a
Explanation: The language syntax has a superficial similarity with C, but the semantics are
of the FPL (functional programming language) variety with stronger affinities with Lisp and
APL. There are many syntaxes in C, which are closely resembled with R.
a) Numeric
b) Character
c) Integer
d) Logical
View Answer
Answer: b
Explanation: All three elements can be expressed as a character. Both paste() and cat()
will printout text to the console by combining multiple character vectors together. The
original data are formatted as character strings so we convert them to R’s Date format for
easier manipulation.
b <- 2:7
a) 4
b) 5
c) 6
d) 0
View Answer
Answer: c
Explanation: Length of b [1] 2 3 4 5 6 7 is 6. We can also create an empty list of a
prespecified length with the vector() function. Data frames are represented as a special
type of list where every element of the list has to have the same length.
a) Numeric
b) Character
c) Integer
d) Logical
View Answer
Answer: a
Explanation: All the elements in ‘b’ can be expressed in numeric. Both paste() and cat()
will printout text to the console by combining multiple character vectors together. The
original data are formatted as character strings so we convert them to R’s Data format for
easier manipulation.
x<-1:3
a) Numeric, Integer
b) Integer, Numeric
c) Integer, Integer
d) Numeric, Numeric
View Answer
Answer: b
Explanation: Here typeof() tells about the data type. They are an important type of object
in R and are used in a variety of statistical modelling applications. You can determine an
object’s type with the typeof function.
Answer: b
Explanation: R language has 6 atomic data types. They are logical, integer, real, complex,
string (or character) and raw. There is also a class for “raw” objects, but they are not
commonly used directly in data analysis.
10. What is the function to set row names for a data frame?
a) row.names()
b) colnames()
c) col.names()
d) column name cannot be set for a data frame
View Answer
Answer: a
Explanation: row.names() is the function to set row names for a data frame. Data frames
have a special attribute called row.names, which indicate information about each row of
the data frame.
Answer: a
Explanation: Single element of a character vector is often referred to as a character string.
Dates are represented by the Date class and can be coerced from a character string using
the as.Date() function. This is a common way to end up with a Date object in R.
Answer: a
Explanation: All R files have an extension .R. R provides a mechanism for recalling and
re-executing previous commands. All S programmed files will have an extension .S. But R
has many functions than S.
3. If the code is stored in the external file, which of the following function is used to call them
to a working directory?
a) exec()
b) source()
c) execute()
d) sourcefile()
View Answer
Answer: b
Explanation: source is available in the file menu. Today R runs on almost any standard
computing platform and operating system. Its open source nature. The copyright for the
primary source code for R is held by the R Foundation and is published under the GNU
General Public License version.
Note: Join free Sanfoundry classes at Telegram or Youtube
advertisement
Answer: c
Explanation: C, C++ and Fortran can be linked. There are a number of people had used
something like C/C++ programming languages to manipulate the R objects.
Answer: c
Explanation: TIBCO is the current owner of the S language. In 2008, Insightful was
acquired by TIBCO for $25 million. As of this writing, TIBCO is the current owner of the S
language and is its exclusive developer.
Answer: a
Explanation: CRAN hosts many add-on packages that can extend the functionality of R.
Connections allow R functions to talk to all different external objects without having to
write custom code for each object.
7. Dataframes can be converted into a matrix by calling the following function data ______
a) matr()
b) matrix()
c) matrixf()
d) matrixfunc()
View Answer
Answer: b
Explanation: as.matrix function should be used to coerce a data frame to a matrix. It might
seem that the as.matrix() function should be used to coerce a data frame to a matrix.
as.logical(x)
a) a b
b) “a” “b”
c) 1 1
d) Error
View Answer
Answer: d
Explanation: It is not possible to coerce, so you will get a Warning. Logical creates a
logical vector of the specified length. Each element of the vector is equal to FALSE.
as.logical attempts to coerce its argument to be of a logical type.
mode(a)
a) Character
b) Numeric
c) Complex
d) Integer
View Answer
Answer: a
Explanation: Mode of the given command is a character. There are a complementary
function writeLines() that takes a character vector and writes each element of the vector
one line at a time to a text file.
Answer: c
Explanation: Calls, expressions and names are the three types of objects that constitute
the R language. There is really only one rule about vectors in R, which is that A vector can
only contain objects of the same class. R objects can have names, which is very useful for
writing readable code and self-describing objects.
Answer: a
Explanation: Anybody is free to download and install these packages and even inspect the
source code. The instructions for obtaining R largely depend on the user’s hardware and
operating system.
2. How to install for a package and all of the other packages on which for depends?
a) install.packages (for, depends = TRUE)
b) R.install.packages (“for”, depends = TRUE)
c) install.packages (“for”, depends = TRUE)
d) install (“for”, depends = FALSE)
View Answer
Answer: c
Explanation: To install a package named for, open up R and type install.packages(“for”).
To install foo and additionally install all of the other packages on which for depends,
instead type install.packages (“for”, depends = TRUE).
Answer: d
Explanation: Type library() at the command prompt to see a list of all available packages
in the library. For total information about the installation of R and add-on packages, see
the R Installation and Administration manual.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
Answer: c
Explanation: The longer programs called scripts, there is too much code to write all at
once at the command prompt. Furthermore, for longer scripts, it is convenient to be able
to only modify a certain piece of the script and run it again in R.
Answer: a
Explanation: script editors are designed to aid the communication and code writing
process. They have all sorts of features including R syntax highlighting, automatic code
completion, delimiter matching, and dynamic help on the R functions.
Answer: d
Explanation: “Recommended” packages also include boot, class, cluster, codetools,
foreign, KernSmooth, lattice, mgcv, nlme, rpart, survival, MASS, nnet, Matrix. There are
about ten thousand packages in R now.
Answer: b
Explanation: GUI elements are usually accessed through a device. All programs running a
GUI use a consistent set of graphical elements so that once the user learns a particular
interface.
8. ____________ provides a point-and-click interface to many basic statistic problems.
a) Commander
b) GUI
c) Console
d) Terminal
View Answer
Answer: a
Explanation: R Commander provides a point-and-click interface to statistical problems. It
is called the “Commander” because every time one makes a selection, the code
corresponding to the task is listed in the output window.
options(digits = 16)20/6
a) 3.33
b) 3.333
c) 3.3333333
d) 3.3333333333333333
View Answer
Answer: d
Explanation: We know that 20/6 is a repeating decimal, We can change the number of
digits displayed with options. This will make the number after the decimal point to extend
for the required amount.
Answer: a
Explanation: An IDE tailored to the needs of interactive data analysis and statistical
programming called R studio. In R studio we can directly interact with R through the inbuilt
functions and packages. We can also download new packages.
Answer: a
Explanation: Compared to other programming languages, the R community tends to be
more focussed on results instead of processes. Knowledge of software engineering best
practice.
Answer: d
Explanation: You are confronted with over 20 years of evolution every time you use R.
Learning R can be hard because there are many special cases in R to remember. R is the
best user of memory.
Answer: d
Explanation: Statistics for relatively advanced users. R has thousands of packages,
designed, maintained, and widely used by statisticians. We can code ourselves if a
command is not present.
Answer: a
Explanation: RStudio is very popular with a nice interface and well thought out, especially
for more advanced usage. It can be a bit buggy, so make sure you update it regularly.
Available on all platforms.
Answer: d
Explanation: The expression a <- 16 creates a variable called a and gives it the value 16
called assignment. The variable on the left is assigned to the value on the right. The left
side should have only a single one.
16. In the expression x <- 4 in R, what is the class of ‘x’ as determined by the `class()’
function?
a) Character
b) Numeric
c) Integer
d) Word
View Answer
Answer: c
Explanation: In R, there is an extension of the numeric or character vectors. They are not
a separate type of object but simply an atomic vector with dimensions.
Answer: b
Explanation: R is a popular programming language and environment for statistical
computing, graphics and also predictive analysis. Dundas BI integrates with an existing R
system at the data cube level via many transforms which you can use to perform data
generation or data processing.
2. In order to use the R-related functionality in Dundas BI, you must have access to an
existing _________
a) Console
b) Terminal
c) Packages
d) R server
View Answer
Answer: d
Explanation: In order to use the R-related functionality in Dundas BI, we must have
access to an existing R server. There are configuration settings in Dundas BI that allow
administrators to specify the details for connecting to the external R server.
3. The open source _________ software is available for Unix, Linux, and Windows
platforms.
a) Rserve
b) BServe
c) CServe
d) Dserve
View Answer
Answer: a
Explanation: The open source Rserve (Binary R Server) software is available for Unix,
Linux, and Windows platforms. However, due to limitations with the Windows version, it is
not recommended for use outside of evaluation purposes.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
Answer: a
Explanation: We can view or modify configuration settings in Dundas BI through an
administration screen, so there’s no need to access the Dundas BI server directly.
Answer: d
Explanation: R has many functions for all types of mathematical objects. For example,
Statistics, Probability, Distributions like Multivariate, Continuous, Simple, Discrete etc.
6. ___________ hosts many add-on packages that can be used to extend the functionality of
R.
a) CRAN
b) GNU
c) R studio
d) 450
View Answer
Answer: a
Explanation: The primary R system is available from the Comprehensive R Archive
Network, also known as CRAN. CRAN also hosts many add-on packages that can be
used to extend the functionality of R.
7. Which function is used to automatically vectorize?
a) lapply()
b) kapply()
c) mapply()
d) happly()
View Answer
answer: c
Explanation: The mapply() function can be used to automatically “vectorize” a function.
What this means is that it can be used to take a function that typically only takes single
arguments and create a new function that can take vector arguments.
Answer: c
Explanation: R (www.r-project.org) is a commonly used free Statistics software. R allows
you to carry out statistical analyses in an interactive mode, as well as allowing simple
programming.
Answer: a
Explanation: A scalar variable was a variable which holds one value at a time. It is a single
component which assumes a range of number or string values. A scalar value is
associated with every point in space.
**********************************************************************************
********************************************************************
Omkar
8. There are more than ________ packages on CRAN that have been developed
by users and programmers around the world.
a) 40
b) 400
c) 4000
d) 40000
View Answer
Answer: c
16. Advanced users can write ___ code to manipulate R objects directly.
a) C, C++
b) C++, Java
c) Java, C
d) Java
View Answer
Answer: a
r<-0:10
r[2]
a) 0
b) 1
c) 2
d) 3
View Answer
Answer: b
Explanation: 1 is the output of the above code as indexing in R starts from 1.
The output can be viewed in the R console. R studio has both R terminal and
the R console. Each output format is implemented as a function in R. You can
customize the output by passing arguments to the function as sub-values of
the output field.
y<-0:5
vector(y)
y[3]
21. In R language, a vector is defined that it can only contain objects of the
________
a) Same class
b) Different class
c) Similar class
d) Any class
View Answer
Answer: a
y <- c(TRUE, 2)
y<-c(2,”t”)
a) Character
b) Numeric
c) Logical
d) Integer
View Answer
Answer: a
a) Character
b) Numeric
c) Logical
d) Integer
View Answer
Answer: b
a) [1] 1 2
b) [1] TRUE TRUE
c) [1] NA NA (Warning message: NAs introduced by coercion)
d) [1] NAN
View Answer
Answer: c
33. How could be the matrix constructed by using the following R code?
a) row-wise
b) column-wise
c) any manner
d) data insufficient
View Answer
Answer: b
Explanation: If nothing is mentioned, matrix is created column-wise. If we
want in row-wise then we have to specify. We have to mention “by row” to
create a matrix in row wise. The filter( ) function is used to extract subsets of
rows from a data frame. This function is similar to the existing subset( )
function.
34. Matrices can be created by row-binding with the help of the following
function.
a) rjoin()
b) rbind()
c) rowbind()
d) rbinding()
View Answer
Answer: b
35. What is the function used to test objects (returns a logical operator) if
they are NA?
a) is.na()
b) is.nan()
c) as.na()
d) as.nan()
View Answer
Answer: a
36. What is the function used to test objects (returns a logical operator) if
they are NaN?
a) as.nan()
b) is.na()
c) as.na()
d) is.nan()
View Answer
Answer: d
?solve
a) help(solve)
b) print(solve)
c) bind(solve)
d) matrix(solve)
View Answer
Answer: a
45. If a command is not complete at the end of a line, R will give a different
prompt, by default it is ____________
a) *
b) –
c) +
d) /
View Answer
Answer: c
46. Command lines entered at the console are limited to about ________ bytes.
a) 3000
b) 4095
c) 5000
d) 6000
View Answer
Answer: b
47. _____ text editor provides more general support mechanisms via ESS for
working interactively with R.
a) EAC
b) Emacs
c) Shell
d) ECAP
View Answer
Answer: b
Explanation: The recall and editing capabilities under UNIX are highly
customizable.
a) Numeric
b) Character
c) Integer
d) Logical
View Answer
Answer: b
b <- 2:7
a) 4
b) 5
c) 6
d) 0
View Answer
Answer: c
52. What are the typeof(x) and mode(x) in the following R syntax?
x<-1:3
a) Numeric, Integer
b) Integer, Numeric
c) Integer, Integer
d) Numeric, Numeric
View Answer
Answer: b
55 In order to use the R-related functionality in Dundas BI, you must have
access to an existing _________
a) Console
b) Terminal
c) Packages
d) R server
View Answer
Answer: d
57. ___________ hosts many add-on packages that can be used to extend the
functionality of R.
a) CRAN
b) GNU
c) R studio
d) 450
View Answer
Answer: a
64. _______ will divert all subsequent output from the console to an external
file.
a) sink
b) div
c) exp
d) exc
View Answer
Answer: a
65. The entities that R creates and manipulates are known as ________
a) objects
b) task
c) container
d) packages
View Answer
Answer: a
66. Which of the following can be used to display the names of (most of) the
objects which are currently stored within R?
a) object()
b) objects()
c) list()
d) class()
View Answer
Answer: b
x <- c(4, 5, 1, 2, 3, 3, 4, 4, 5, 6)
x <- as.factor(x)
a) x becomes a factor
b) x is a factor
c) x does not exist
d) x is not a vector
View Answer
Answer: a
print( sqrt(2) )
a) 1.414314
b) 1.414214
c) Error
d) 14.1414
View Answer
Answer: b
70. What will be the output of the following R function?
d <- date()
d
nchar()
a) no. of characters
b) first 5 characters
c) last 5 characters
d) Does not exist
View Answer
Answer: a
Sys.Date()
a) Tomorrow date
b) Present date
c) Some date
d) Yesterday date
View Answer
Answer: b
Sys.time()
77. . If you explicitly want an integer, you need to specify the _____ suffix.
a) D
b) R
c) L
d) K
View Answer
Answer: c
79. Attributes of an object (if any) can be accessed using the ______ function.
a) objects()
b) attrib()
c) attributes()
d) obj()
View Answer
Answer: c
80. R objects can have attributes, which are like ________ for the object.
a) metadata
b) features
c) expression
d) dimensions
View Answer
Answer: a
a) 10
b) 0 0 0 0 0 0 0 0 0 0
c) 01
d) 00120
View Answer
Answer: b
83. The ________ function can be used to create vectors of objects by
concatenating things together.
a) cp()
b) c()
c) concat()
d) con()
View Answer
Answer: b
> x <- 6
> class(x)
a) “integer”
b) “numeric”
c) “real”
d) “imaginary”
View Answer
Answer: b
> sqrt(-17)
a) -4.02
b) 4.02
c) NaN
d) 3.67
View Answer
Answer: c
Explanation: These metadata can be very useful in that they help to describe
the object.
b)
c)
d)
91. _______ function returns a vector of the same size as x with the elements
arranged in increasing order.
a) sort()
b) orderasc()
c) orderby()
d) sequence()
View Answer
Answer: a
93. Which of the following statement would print “0” “1” “2” “3” “4” “5” “6”
for the following R code?
a) as.character(x)
b) as.logical(x)
c) as.numeric(x)
d) as.num(y)
View Answer
Answer: a
Explanation: as.character would print number from 0 to 6.
94. Point out the correct statement?
a) rep() is be used for replicating an object in various complicated ways
b) seq() function has four arguments
c) sequence() is a more general facility for generating sequences
d) numerical vectors are generated by conditions
View Answer
Answer: a
a) Warning
b) Error
c) Abnormal termination
d) Prints x
View Answer
Answer: a
96. What will be the output of the following R code?
a) a b c
b) NA NA NA
c) 0 1 2
d) 6 8 9
View Answer
Answer: b
b)
c)
d)
View Answer
Answer: a
a) 3 2
b) 2 3
c) 2 2
d) 4 5
View Answer
Answer: b
Explanation: Matrices are constructed column-wise.
a) 1 2 3 4 5 6 7 8 9 10
b) 1 2 3 4 5 6 7 8 9 10 11
c) 0 1 2 3 4 5 6 7 8 9 10
d) 10 9 8 6 5 4 2 3 1 2
View Answer
Answer: a
101. What will be the output of the following R code?
a)
x y
[1,] 6 10
[2,] 7 11
[3,] 8 12
b)
x y
[1,] 1 10
[2,] 2 11
[3,] 3 12
c)
x y
[1,] 1 4
[2,] 2 5
[3,] 3 6
d)
x y
[1,] 1 6
[2,] 2 5
[3,] 3 10
View Answer
Answer: b
a <- c(1,2,5.3,6,-2,4)
a) Numeric
b) Character
c) Integer
d) Logical
Answer: a
103. 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 different
View Answer
Answer: b
104. ___________ provides optional labels with the columns and rows.
a) Disnames
b) Dimnames
c) Denmes
d) Demnesd
View Answer
Answer: b
105. ________ are similar to matrices but can have more than two dimensions.
a) Functions
b) Packages
c) Arrays
d) Columns
View Answer
Answer: c
106. 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) Databases
View Answer
Answer: c
109. The ________ stores the nominal values as a vector of integers in the
range of 1 to unique values in the nominal variable.
a) Factor
b) Matrix
c) Lists
d) Functions
View Answer
Answer: a
116. Which function takes a dim attribute which creates the required number
of dimensions?
a) Vector
b) Array
c) Matrix
d) Lists
View Answer
Answer: b
117. Factors are the r-objects which are created using a _________
a) Vector
b) Matrix
c) Lists
d) Array
View Answer
Answer: a
120. vectors can be one of two types namely atomic vectors and _______
a) Matrix
b) Vector
c) Lists
d) Array
View Answer
Answer: c
122. 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 same
View Answer
Answer: a
125. Which is the basic data structure of R containing the same type of data?
a) Functions
b) Array
c) Vector
d) Lists
View Answer
Answer: c
126. In R using the function, ________ one can check the data type of vector.
a) Typeof()
b) Castof()
c) Function()
d) C()
View Answer
Answer: a
127. __________are Data frames which contain lists of homogeneous data in a
tabular format.
a) Matrix
b) Vector
c) Lists
d) Array
View Answer
Answer: c
128. The four most frequently used types of data objects in R are vectors,
matrices, data frames and ________
a) Function
b) Lists
c) Packages
d) Interfaces
View Answer
Answer: b
134. To bind a row onto an already existing matrix, the ______ function can be
used.
a) Rbind
b) Sbnd
c) Gbind
d) Sbind
View Answer
Answer: a
136. Using the ________ vector, we create a species factor and bind it to the
columns of iris.df.
a) snames
b) rnames
c) jnames
d) fnames
View Answer
Answer: a
137. Accessing elements is achieved through a process called ________
a) Indexing
b) Outdexing
c) Highlighting
d) Scrapping
View Answer
Answer: a
138. Which are indexed by either row or column using a specific name or
number?
a) Datasets
b) Data frames
c) Data
d) Functions
View Answer
Answer: b
139. What should we use to access elements with a value greater than five?
a) Subsetting commands
b) Use functions
c) Packages
d) Interfaces
View Answer
Answer: a
145. Which function can be used to determine the names assigned to a list?
a) Names
b) Name
c) Nam
d) Nem
View Answer
Answer: a
146. Joining two lists can be achieved either using the _________ function.
a) Concat
b) Join
c) Reduce
d) Delete
View Answer
Answer: a
150. The _________ function returns a list of densities (y) corresponding to bin
values (x).
a) Spline
b) Density
c) Lists
d) Locator
View Answer
Answer: a
a)
a b
1 1 a
b)
a b
1 2 b
c)
a b
2 1 a
d)
b a
1 a a
View Answer
Answer: a
160. Main way to read the data back in (parsing it) using the function.
a) dput()
b) write()
c) read()
d) dget()
View Answer
Answer: d
161. Multiple objects can be de parsed at once using the ______ function.
a) dput()
b) write()
c) dump()
d) dget()
View Answer
Answer: a
162. Multiple objects can be de parsed at once and read back using function
_____
a) source()
b) read()
c) dget()
d) dput()
View Answer
Answer: a
165. 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()
View Answer
Answer: b
166. .rda extension used when saving data with function __________
a) save()
b) save.image()
c) save and save.image functions
d) serialize()
View Answer
Answer: c
167. 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 vector
View Answer
Answer: a
168. 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()
View Answer
Answer: d
171. Which of the following R statement will save the output to the file for
following R code?
172. 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”)
View Answer
Answer: b
176. Connections to text files can be created with the ________ function.
a) url
b) gzfile
c) bzfile
d) file
View Answer
Answer: d
178. 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 <- read.csv(“foo.txt”)
b) data <- read.csvo(“foo.txt”)
c) data <- readonly.csv(“foo.txt”)
d) data <- getonly.csv(“foo.txt”)
View Answer
Answer: a
180. Which of the following extracts first element from the following R vector?
a) x[10]
b) x[1]
c) x[0]
d) x[2]
View Answer
Answer: b
181. Point out the correct statement?
a) There are three operators that can be used to extract subsets of R objects
b) The [ operator is used to extract elements of a list or data frame by literal
name
c) The [[ operator is used to extract elements of a list or data frame by string
name
d) There are five operators that can be used to extract subsets of R objects
View Answer
Answer: a
Explanation: Three operators are [,[[ and $.
182. Which of the following extracts first four element from the following R
vector?
> x <- c("a", "b", "c", "c", "d", "a")
a) x[0:4]
b) x[1:4]
c) x[0:3]
d) x[4:3]
View Answer
Answer: b
a) 3
b) 2
c) 1
d) 0
View Answer
Answer: a
186. Which of the following R code extracts the second column for the
following matrix?
a)
b)
c)
d) Error
View Answer
Answer: a
Explanation: By default, when a single element of a matrix is retrieved, it is
returned as a vector of length 1 rather than a $1\times 1$ matrix.
a)
$foo
[1] 1 2 3 4
$bar
[1] 0.6
b)
$foo
[1] 0 1 2 3 4
$bar
[1] 0 0.6
c)
$foo
[1] 0 1 2 3 4
$bar
[1] 0.6
d) Error
View Answer
Answer: a
190. Which of the following code extracts 1st element of the 2nd element?
a) x[[c(2, 1)]]
b) x[[c(1, 2)]]
c) x[[c(2, 1,1)]]
d) x[[(2, 2,1)]]
View Answer
Answer: a
a) x+y
b) x-y
c) x/y
d) x–y
View Answer
Answer: b
a) 7 9 11 13
b) 7 9 11 13 14
c) 9 7 11 13
d) NULL
View Answer
Answer: a
a) 1 2 3 4
b) FALSE FALSE TRUE TRUE
c) 1 2 3 4 5
d) 5 4 3 1 2 1
View Answer
Answer: b
195. What will be the output of the following R code?
[,1] [,2]
[1,] 10 30
[2,] 20 40
b)
[,1] [,2]
[1,] 10 30
[2,] 30 40
c)
[,1] [,2]
[1,] 20 30
[2,] 20 40
d) Error
View Answer
Answer: a
a) “1970-01-01”
b) “1970-01-02”
c) “1970-02-01”
d) “1970-02-02”
View Answer
Answer: a
a) “POSIXct” “POSIXt”
b) “POSIXXt” “POSIXt”
c) “POSIXct” “POSIct”
d) “POSIXt” “POSIXt”
View Answer
Answer: a
200. Which of the following function gives the day of the week?
a) weekdays
b) months
c) quarters
d) semesters
View Answer
Answer: a
201. 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 mentioned
View Answer
Answer: d
204. Which of the following return a subset of the columns of a data frame?
a) select
b) retrieve
c) get
d) set
View Answer
Answer: a
209. The _______ operator is used to connect multiple verb actions together
into a pipeline.
a) pipe
b) piper
c) start
d) end
View Answer
Answer: a
210. 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”)
View Answer
Answer: b
215. 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) arrange
View Answer
Answer: c
217. There is an SQL interface for relational databases via the _______
package.
a) DIB
b) DB2
c) DBI
d) DIB21
View Answer
Answer: c
218. dplyr can be integrated with the ________ package for large fast tables.
a) data.table
b) read.table
c) data.data
d) table.read
View Answer
Answer: a
b)
c)
d)
View Answer
Answer: c
230. In practice, Line of best fit or regression line is found when _____________
a) Sum of residuals (∑(Y – h(X))) is minimum
b) Sum of the absolute value of residuals (∑|Y-h(X)|) is maximum
c) Sum of the square of residuals ( ∑ (Y-h(X))2) is minimum
d) Sum of the square of residuals ( ∑ (Y-h(X))2) is maximum
View Answer
Answer: c
231. If Linear regression model perfectly first i.e., train error is zero, then
_____________________
a) Test error is also always zero
b) Test error is non zero
c) Couldn’t comment on Test error
d) Test error is equal to Train error
View Answer
Answer: c
Explanation: Test Error depends on the test data. If the Test data is an exact
representation of train data then test error is always zero. But this may not
be the case.
232. Which of the following metrics can be used for evaluating regression
models?
i) R Squared
iii) F Statistics
a) ii and iv
b) i and ii
c) ii, iii and iv
d) i, ii, iii and iv
View Answer
Answer: d
Explanation: These (R Squared, Adjusted R Squared, F Statistics, RMSE /
MSE / MAE) are some metrics which you can use to evaluate your regression
model.
233. How many coefficients do you need to estimate in a simple linear
regression model (One independent variable)?
a) 1
b) 2
c) 3
d) 4
View Answer
Answer: b
Explanation: In simple linear regression, there is one independent variable so
2 coefficients (Y=a+bx+error).
234. In a simple linear regression model (One independent variable), If we
change the input variable by 1 unit. How much output variable will change?
a) by 1
b) no change
c) by intercept
d) by its slope
View Answer
Answer: d
Explanation: For linear regression Y=a+bx+error. If neglect error then
Y=a+bx. If x increases by 1, then Y = a+b(x+1) which implies Y=a+bx+b. So
Y increases by its slope.
239. Which of the following code create n samples of size “size” with
probability prob from the binomial?
a) z <- rinom(n,size,prob)
b) z <- rbinom(n,size,prob)
c) z <- binom(n,size,prob)
d) z >- nom(n,size,prob)
View Answer
Answer: b
240.
241.
242.
243.
244.