0% found this document useful (0 votes)
8 views

3- R Programming main file

Uploaded by

omkarmalap
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

3- R Programming main file

Uploaded by

omkarmalap
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 137

R Programming:

1. Is It possible to inspect the source code of R?


a) Yes
b) No
c) Can’t say
d) Some times

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).

3. __________ function is used to watch for all available packages in library.


a) lib()
b) fun.lib()
c) libr()
d) library()

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.

4. The longer programs are called ____________


a) Files
b) Structures
c) Scripts
d) Data

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.

6. Which of the following is a “Recommended” package in R?


a) Util
b) Lang
c) Stats
d) Spatial

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.

7. Full Form of GUI is ___________________


a) Guided User Interface
b) Graphical User Interface
c) Guided Used Interface
d) Graphical User Interval

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.

8. ____________ provides a point-and-click interface to many basic statistic problems.


a) Commander
b) GUI
c) Console
d) Terminal

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.

9. What will be the output of the following R code?

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.

10. In which IDE we can interact with R?


a) R studio
b) Console
c) GCC
d) Power shell

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.

11. Which programming language is more based on the results?


a) R
b) C
c) C++
d) Java

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.

12. Why learning R becomes tough?


a) Special files
b) Functions
c) Packages
d) Special Cases

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.

13. R is mostly used in ______________


a) Problem solving
b) Statistics
c) Probability
d) All of the mentioned
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.

14. Why is it needed for R studio to update regularly?


a) Bugs
b) More Functions
c) Methods
d) For more packages

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.

15. What is the meaning of “<-“?


a) Functions
b) Loops
c) Addition
d) Assignment

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.

1. What is output of getOption(“defaultPackages”) in R studio?


a) Installs a new package
b) Shows default packages in R
c) Error
d) Nothing will print

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.

2. What will be the output of the following R code?

x <- c(3, 7, NA, 4, 7)

y <- c(5, NA, 1, 2, 2)

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.

3. R language is a dialect of which of the following languages?


a) S
b) C
c) MATLAB
d) SAS

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.

4. R language has superficial similarity with _________


a) C
b) Python
c) MATLAB
d) SAS

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 <- c(1,” a”, FALSE)

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.

6. What is the length of b?

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.

7. What is the mode of b in the following R code?

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.

8. What are the typeof(x) and mode(x) in the following R syntax?

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.

1. A single element of a character vector is referred as ________


a) Character string
b) String
c) Data strings
d) Raw data

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.

2. R files has an extension ______


a) .R
b) .S
c) .Rp
d) .c

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.

4. Advanced programmers can write ______ code to manipulate R objects.


a) Python
b) Java
c) C
d) Java Script

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.

5. In ________ Insightful purchased the S language from Lucent for $2 million.


a) 2002
b) 2003
c) 2004
d) 2005

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.

8. What will be the output of the following R code?

x <- (“a”, “b”)


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.

9. What will be the output of the following R code?

a <- (“a” , “b”)

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.

10. Which of the following is not an object of R?


a) calls
b) expressions
c) strings
d) names

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.

1. What is output of getOption(“defaultPackages”) in R studio?


a) Installs a new package
b) Shows default packages in R
c) Error
d) Nothing will print
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.

2. What will be the output of the following R code?

x <- c(3, 7, NA, 4, 7)

y <- c(5, NA, 1, 2, 2)

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.

3. R language is a dialect of which of the following languages?


a) S
b) C
c) MATLAB
d) SAS

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.

4. R language has superficial similarity with _________


a) C
b) Python
c) MATLAB
d) SAS

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 <- c(1,” a”, FALSE)


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.

6. What is the length of b?

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.

7. What is the mode of b in the following R code?

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.

8. What are the typeof(x) and mode(x) in the following R syntax?

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.

1. A single element of a character vector is referred as ________


a) Character string
b) String
c) Data strings
d) Raw data

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.

2. R files has an extension ______


a) .R
b) .S
c) .Rp
d) .c

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.

4. Advanced programmers can write ______ code to manipulate R objects.


a) Python
b) Java
c) C
d) Java Script

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.

5. In ________ Insightful purchased the S language from Lucent for $2 million.


a) 2002
b) 2003
c) 2004
d) 2005

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.
8. What will be the output of the following R code?

x <- (“a”, “b”)

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.

9. What will be the output of the following R code?

a <- (“a” , “b”)

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.

10. Which of the following is not an object of R?


a) calls
b) expressions
c) strings
d) names

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.

1. What is output of getOption(“defaultPackages”) in R studio?


a) Installs a new package
b) Shows default packages in R
c) Error
d) Nothing will print

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.

2. What will be the output of the following R code?

x <- c(3, 7, NA, 4, 7)

y <- c(5, NA, 1, 2, 2)

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.

3. R language is a dialect of which of the following languages?


a) S
b) C
c) MATLAB
d) SAS

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.

4. R language has superficial similarity with _________


a) C
b) Python
c) MATLAB
d) SAS

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 <- c(1,” a”, FALSE)

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.

6. What is the length of b?

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.

7. What is the mode of b in the following R code?

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.

8. What are the typeof(x) and mode(x) in the following R syntax?

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.

1. Is It possible to inspect the source code of R?


a) Yes
b) No
c) Can’t say
d) Some times

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).

3. __________ function is used to watch for all available packages in library.


a) lib()
b) fun.lib()
c) libr()
d) library()

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.

4. The longer programs are called ____________


a) Files
b) Structures
c) Scripts
d) Data

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.

6. Which of the following is a “Recommended” package in R?


a) Util
b) Lang
c) Stats
d) Spatial

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.

7. Full Form of GUI is ___________________


a) Guided User Interface
b) Graphical User Interface
c) Guided Used Interface
d) Graphical User Interval
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.

8. ____________ provides a point-and-click interface to many basic statistic problems.


a) Commander
b) GUI
c) Console
d) Terminal

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.

9. What will be the output of the following R code?

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.

10. In which IDE we can interact with R?


a) R studio
b) Console
c) GCC
d) Power shell

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.

11. Which programming language is more based on the results?


a) R
b) C
c) C++
d) Java
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.

12. Why learning R becomes tough?


a) Special files
b) Functions
c) Packages
d) Special Cases

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.

13. R is mostly used in ______________


a) Problem solving
b) Statistics
c) Probability
d) All of the mentioned

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.

14. Why is it needed for R studio to update regularly?


a) Bugs
b) More Functions
c) Methods
d) For more packages

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.

15. What is the meaning of “<-“?


a) Functions
b) Loops
c) Addition
d) Assignment

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.

1. What is output of getOption(“defaultPackages”) in R studio?


a) Installs a new package
b) Shows default packages in R
c) Error
d) Nothing will print

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.

2. What will be the output of the following R code?

x <- c(3, 7, NA, 4, 7)

y <- c(5, NA, 1, 2, 2)

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.

3. R language is a dialect of which of the following languages?


a) S
b) C
c) MATLAB
d) SAS
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.

4. R language has superficial similarity with _________


a) C
b) Python
c) MATLAB
d) SAS

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 <- c(1,” a”, FALSE)

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.

6. What is the length of b?

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.

7. What is the mode of b in the following R code?

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.

8. What are the typeof(x) and mode(x) in the following R syntax?

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.

1. A single element of a character vector is referred as ________


a) Character string
b) String
c) Data strings
d) Raw data
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.

2. R files has an extension ______


a) .R
b) .S
c) .Rp
d) .c

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.

4. Advanced programmers can write ______ code to manipulate R objects.


a) Python
b) Java
c) C
d) Java Script

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.

5. In ________ Insightful purchased the S language from Lucent for $2 million.


a) 2002
b) 2003
c) 2004
d) 2005

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.

8. What will be the output of the following R code?

x <- (“a”, “b”)

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.

9. What will be the output of the following R code?

a <- (“a” , “b”)

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.

10. Which of the following is not an object of R?


a) calls
b) expressions
c) strings
d) names

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.

1. Find the following type of vector?

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).

3. ___________ provides optional labels with the columns and rows.


a) Disnames
b) Dimnames
c) Denmes
d) Demnesd
Answer: b
Clarification: byrow=TRUE indicates that the matrix should be filled by rows. byrow=FALSE indicates
that the matrix should be filled by columns (the default). dimnames provides optional labels with the
columns and rows.

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.

6. An ordered collection of objects or components are called ________


a) Data frames
b) Datasets
c) Databases
d) Lists

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.

1. Which function is used to combine the elements into a vector?


a) C()
b) D()
c) E()
d) F()

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.

3. A _________ is a two-dimensional rectangular data set.


a) Vector
b) Lists
c) Matrix
d) Functions

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.

5. Factors are the r-objects which are created using a _________


a) Vector
b) Matrix
c) Lists
d) Array

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.

6. Factors are created using the _______ function.


a) C()
b) Function()
c) Array()
d) Lists()
Answer: b
Clarification: Factors are created using the factor() function. The labels are always character
irrespective of whether it is numeric or character or also Boolean etc. in the vector. The nlevels
functions will give the count of levels.

7. By what function we can create data frames?


a) Data.frames()
b) Data.sets ()
c) Function ()
d) C ()

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.

9. Lists can be coerced with which function?


a) As.lists
b) Has.lists
c) In.lists
d) Co.lists

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.

12. Decimal values are referred as ________ data types in R.


a) Numeric
b) Character
c) Integer
d) Lists

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.

1. R was created by?

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.

2. R allows integration with the procedures written in the?

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.

4. R made its first appearance in?

A. 1992
B. 1995
C. 1993
D. 1994

View Answer

Ans : C

Explanation: R made its first appearance in 1993.

5. Which of the following is true about R?

A. R is a well-developed, simple and effective programming language


B. R has an effective data handling and storage facility
C. R provides a large, coherent and integrated collection of tools for data analysis.
D. All of the above

View Answer
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.

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 ‘}’).

8. R language is a dialect of which of the following languages?

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.

9. How many atomic vector types does R have?

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.

10. R files has an extension _____.

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

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""

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

4. Data Frames are created using the?

A. frame() function
B. data.frame() function
C. data() function
D. frame.data() function

View Answer

5. Which functions gives the count of levels?

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.

6. Point out the correct statement?


A. Empty vectors can be created with the vector() function
B. A sequence is represented as a vector but can contain objects of different classes
C. "raw” objects are commonly used directly in data analysis
D. The value NaN represents undefined value

View Answer

7. What will be the output of the following R code?

> x <- vector(""numeric"", length = 10)

>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.

8. What will be output for the following code?

> 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.

10. What will be the output of the following R code?

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

> dim(m)

A. 3 3
B. 3 2
C. 2 3
D. 2 2

View Answer

Ans : C

Explanation: Matrices are constructed column-wise.


1. Point out the correct statement :

A. Empty vectors can be created with the vector() function

B. A sequence is represented as a vector but can contain objects of different classes

C. raw" objects are commonly used directly in data analysis

D. None of the mentioned

Answer: Option A

Explanation:

A vector can only contain objects of the same class

2. Point out the correct statement :

A. The value NaN represents undefined value

B. Number Inf represents infinity in R

C. NaN can also be thought of as a missing value

D. None

Answer: Option B

Explanation:

This allows us to represent entities like 1 / 0.

3. Data frames can be converted to a matrix by calling data._______

A. matr()

B. mat()

C. matrix()

D. All of the mentioned


Answer: Option C

Explanation:

as.matrix() function should be used to coerce a data frame to a matrix.

4. Which of the following statement changes column name to h and f ?

A. colnames(m) <- c("h", "f")

B. columnnames(m) <- c("h", "f")

C. rownames(m) <- c("h", "f")

D. None of the mentioned

Answer: Option A

Explanation:

Column names and row names can be set separately using the colnames() and rownames()
functions.

5. Point out the wrong statement :

A. matrices or more generally arrays are multi-dimensional generalizations of vectors

B. factors provide compact ways to handle categorical data

C. vectors provide a convenient way to return the results of a statistical computation

D. All of the mentioned

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

D. None of the mentioned

Answer: Option A

Explanation:

We can also create an empty list of a pre-specified length with the vector() function.

7. What would the following code print ?

x - c("a", "b", "c")

as.logical(x)

A. a b c

B. NA NA NA

C. 0 1 2

D. All of the mentioned

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

D. None of the mentioned

Answer: Option B

Explanation:

Matrices are constructed column-wise.

9. What would be the output of the following code ?

sqrt(-17)

A. -4.02

B. 4.02

C. NaN

D. None of the mentioned

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.

2. Which of the following truncates real x to integers ?

A. as.numeric(x)

B. as.integer(x)

C. as.order(x)

D. All of the mentioned

Answer: Option B

Explanation:

Compare to round(x,0) in R.

3. Which of the following may be used for linear regression ?

A. X %*% Y

B. solve(A)

C. solve(A,B)
D. All of the mentioned

Answer: Option C

Explanation:

solve(A,B) implies inverse of A * B.

4. ________ provides needed string operators in R.

A. str

B. forecast

C. stringr

D. All of the mentioned

Answer: Option C

Explanation:

stringr is remarkably easy to use.

5. Which of the following syntax is used to install forecast package ?

A. install.pack(forecast")

B. install.packages(cast")

C. install.packages(forecast")

D. All of the mentioned

Answer: Option C

Explanation:

forecast is used for time series analysis.


6. ________ contains tools for Approximate Bayesian Computation (ABC).

A. str

B. abc

C. zyz

D. All of the mentioned

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

D. All of the mentioned

Answer: Option B

Explanation:

saves is used for faster loading of variables.

8. Which of the following involves predicting a categorical response ?

A. Regression

B. Summarization

C. Clustering
D. Classification

Answer: Option D

Explanation:

Classification techniques are widely used in data mining to classify data.

9. Which of the following groups find the correlation matrix ?

A. factor.model

B. col.max(x)

C. stem

D. which.max(x)

Answer: Option A

Explanation:

factor.congruence is used to find the factor congruence coefficients.


**********************************************************************************
********************************************************************

Rajput

R language

1. R was created by?


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.

2. R allows integration with the procedures written in the?


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.

4. R made its first appearance in?


A. 1992
B. 1995
C. 1993
D. 1994

View Answer
Ans : C
Explanation: R made its first appearance in 1993.

5. Which of the following is true about R?


A. R is a well-developed, simple and effective programming language
B. R has an effective data handling and storage facility
C. R provides a large, coherent and integrated collection of tools for data
analysis.
D. All of the above

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.

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 ‘}’).

8. R language is a dialect of which of the following languages?


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.

9. How many atomic vector types does R have?


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.

10. R files has an extension _____.


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
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""

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

4. Data Frames are created using the?


A. frame() function
B. data.frame() function
C. data() function
D. frame.data() function

View Answer
Ans : B
Explanation: Data Frames are created using the data.frame() function

5. Which functions gives the count of levels?


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.

6. Point out the correct statement?


A. Empty vectors can be created with the vector() function
B. A sequence is represented as a vector but can contain objects of different
classes
C. "raw” objects are commonly used directly in data analysis
D. The value NaN represents undefined value

View Answer
Ans : A
Explanation: A vector can only contain objects of the same class.

7. What will be the output of the following R code?


> x <- vector(""numeric"", length = 10)

> 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.

8. What will be output for the following code?


> 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.

10. What will be the output of the following R code?


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

> dim(m)

A. 3 3
B. 3 2
C. 2 3
D. 2 2

View Answer
Ans : C
Explanation: Matrices are constructed column-wise.

1. Which loop executes a sequence of statements multiple times and


abbreviates the code that manages the loop variable?
A. for
B. while
C. do-while
D. repeat
View Answer
Ans : D
Explanation: repeat loop : Executes a sequence of statements multiple times and
abbreviates the code that manages the loop variable.

2. Which of the following true about for loop?


A. Repeats a statement or group of statements while a given condition is true. It
tests the condition before executing the loop body.
B. it tests the condition at the end of the loop body.
C. Both A and B
D. None of the above

View Answer
Ans : B
Explanation: for loop : Like a while statement, except that it tests the condition at the end
of the loop body.

3. Which statement simulates the behavior of R switch?


A. Next
B. Previous
C. break
D. goto

View Answer
Ans : A
Explanation: The next statement simulates the behavior of R switch.

4. In which statement terminates the loop statement and transfers


execution to the statement immediately following the loop?
A. goto
B. switch
C. break
D. label

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.

6. The mapply() function is a multivariate apply of sorts which applies


a function in parallel over a set of arguments.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

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.

7. Which of the following is valid body of split function?


A. function (x, f)
B. function (x, f, drop = FALSE, …)
C. function (x, drop = FALSE, …)
D. function (drop = FALSE, …)

View Answer
Ans : B
Explanation: x is a vector (or list) or data frame

8. Which of the following character skip during execution?


v <- LETTERS[1:6]
for ( i in v) {

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""

9. What will be output for the following code?


v <- LETTERS[1]

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

1. An R function is created by using the keyword?


A. fun
B. function
C. declare
D. extends

View Answer
Ans : B
Explanation: An R function is created by using the keyword function.

2. What will be output for the following code?


print(mean(25:82))

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

3. Point out the wrong statement?


A. Functions in R are “second class objects”
B. The writing of a function allows a developer to create an interface to the
code, that is explicitly specified with a set of parameters
C. Functions provides an abstraction of the code to potential users
D. Writing functions is a core activity of an R programmer

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.

4. What will be output for the following code?


> paste("a", "b", se = ":")

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.

5. Which function in R language is used to find out whether the means


of 2 groups are equal to each other or not?
A. f.tests ()
B. l.tests ()
C. t.tests ()
D. p.tests ()

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.

6. What will be the output of log (-5.8) when executed on R console?


A. NA
B. NAN
C. 0.213
D. Error

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(-).

7. Which function is preferred over sapply as vapply allows the


programmer to specific the output type?
A. Lapply
B. Japply
C. Vapply
D. Zapply

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().

8. How will you check if an element is present in a vector?


A. Match()
B. Dismatch()
C. Mismatch()
D. Search()

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.

10. In the base graphics system, which function is used to add


elements to a plot?
A. Boxplot()
B. Text()
C. Treat()
D. Both A and B

View Answer
Ans : D
Explanation: In the base graphics system, boxplot or text function is used to add
elements to a plot.

1. Which of the following syntax is used to install forecast package?


A. install.pack("forecast")
B. install.packages("cast")
C. install.packages("forecast")
D. install.pack("forecastcast")

View Answer
Ans : C
Explanation: forecast is used for time series analysis

2. Which splits a data frame and returns a data frame?


A. apply
B. ddply
C. stats
D. plyr

View Answer
Ans : B
Explanation: ddply splits a data frame and returns a data frame.

3. Which of the following is an R package for the exploratory analysis


of genetic and genomic data?
A. adeg
B. adegenet
C. anc
D. abd

View Answer
Ans : B
Explanation: This package contains Classes and functions for genetic data analysis
within the multivariate framework.

4. Which of the following contains functions for processing uniaxial


minute-to-minute accelerometer data?
A. accelerometry
B. abc
C. abd
D. anc

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.

5. ______ Uses Grieg-Smith method on 2 dimensional spatial data.


A. G.A.
B. G2db
C. G.S.
D. G1DBN

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.

7. What will be the output of the following R code?


install.packages(c("devtools", "roxygen2"))

A. Develops the tools


B. Installs the given packages
C. Exits R studio
D. Nothing happens

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.

8. A bundled package is a package that’s been compressed into a ______


file.
A. Double
B. Single
C. Triple
D. No File

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.

10. DESCRIPTION uses a very simple file format called DCF.


A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

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.

1. The most convenient way to use R is at a graphics workstation running a ________


system.
a) windowing
b) running
c) interfacing
d) matrix
View Answer

Answer: a
Explanation: Most classical statistics and much of the latest methodology is available for
use with R.

2. 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
Answer: b
Explanation: help command is used for knowing details of particular command in R.

3. Which of the following is default prompt for UNIX environment?


a) >
b) >>
c) <
d) <<
View Answer

Answer: a
Explanation: When you use the R program it issues a prompt when it expects input
commands.

4. Which of the following will start the R program?


a) $ R
b) > R
c) * R
d) @ R
View Answer

Answer: a
Explanation: At this point R commands may be issued.

Note: Join free Sanfoundry classes at Telegram or Youtube

advertisement

5. Point out the wrong statement?


a) Windows versions of R have other optional help system also
b) The help.search command (alternatively ??) allows searching for help in various ways
c) R is case insensitive as are most UNIX based packages, so A and a are different symbols
and would refer to different variables
d) $ R is used to start the R program
View Answer

Answer: c
Explanation: R is an expression language with a very simple syntax.

6. Which of the following statement is alternative to _________

Take R Programming Practice Tests - Chapterwise!


Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

?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.

7. Elementary commands in R consist of either _______ or assignments.


a) utilstats
b) language
c) expressions
d) packages
View Answer

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.

1. What is output of getOption(“defaultPackages”) in R studio?


a) Installs a new package
b) Shows default packages in R
c) Error
d) Nothing will print
View Answer

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.

2. What will be the output of the following R code?

x <- c(3, 7, NA, 4, 7)

y <- c(5, NA, 1, 2, 2)

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.

Note: Join free Sanfoundry classes at Telegram or Youtube

advertisement

3. R language is a dialect of which of the following languages?


a) S
b) C
c) MATLAB
d) SAS
View Answer

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.

Take R Programming Tests Now!

4. R language has superficial similarity with _________


a) C
b) Python
c) MATLAB
d) SAS
View Answer

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.

5. What is the mode of ‘a’ in the following R code?

a <- c(1,” a”, FALSE)

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.

6. What is the length of b?

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.

7. What is the mode of b in the following R code?

b <- c(TRUE, TRUE, 1)

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.

8. 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
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.

9. How many atomic vector types does R have?


a) 5
b) 6
c) 8
d) 10
View Answer

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.

1. A single element of a character vector is referred as ________


a) Character string
b) String
c) Data strings
d) Raw data
View Answer

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.

2. R files has an extension ______


a) .R
b) .S
c) .Rp
d) .c
View Answer

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

4. Advanced programmers can write ______ code to manipulate R objects.


a) Python
b) Java
c) C
d) Java Script
View Answer

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.

5. In ________ Insightful purchased the S language from Lucent for $2 million.


a) 2002
b) 2003
c) 2004
d) 2005
View Answer

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.

Take R Programming Mock Tests - Chapterwise!


Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

6. Functionality of R is divided into a number of __________


a) Functions
b) Domains
c) Packages
d) Files
View Answer

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.

8. What will be the output of the following R code?

x <- (“a”, “b”)

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.

9. What will be the output of the following R code?

a <- (“a” , “b”)

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.

10. Which of the following is not an object of R?


a) calls
b) expressions
c) strings
d) names
View Answer

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.

1. Is It possible to inspect the source code of R?


a) Yes
b) No
c) Can’t say
d) Some times
View Answer

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).

3. __________ function is used to watch for all available packages in library.


a) lib()
b) fun.lib()
c) libr()
d) library()
View Answer

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

4. The longer programs are called ____________


a) Files
b) Structures
c) Scripts
d) Data
View Answer

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.

5. Scripts will run on ___________________


a) Script Editors
b) Console
c) Terminal
d) GCC Compiler
View Answer

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.

Check this: Programming MCQs | R Programming Books

6. Which of the following is a “Recommended” package in R?


a) Util
b) Lang
c) Stats
d) Spatial
View Answer

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.

7. Full Form of GUI is ___________________


a) Guided User Interface
b) Graphical User Interface
c) Guided Used Interface
d) Graphical User Interval
View Answer

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.

9. What will be the output of the following R code?

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.

10. In which IDE we can interact with R?


a) R studio
b) Console
c) GCC
d) Power shell
View Answer

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.

11. Which programming language is more based on the results?


a) R
b) C
c) C++
d) Java
View Answer

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.

12. Why learning R becomes tough?


a) Special files
b) Functions
c) Packages
d) Special Cases
View Answer

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.

13. R is mostly used in ______________


a) Problem solving
b) Statistics
c) Probability
d) All of the mentioned
View Answer

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.

14. Why is it needed for R studio to update regularly?


a) Bugs
b) More Functions
c) Methods
d) For more packages
View Answer

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.

15. What is the meaning of “<-“?


a) Functions
b) Loops
c) Addition
d) Assignment
View Answer

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.

1. Which language is best for the statistical environment?


a) C
b) R
c) Java
d) Python
View Answer

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

4. Modification in Dundas BI is done ______________


a) Directly
b) Indirectly
c) Need access to Server
d) Not known
View Answer

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.

5. R has many functions regarding ________________


a) Statistics, Biotechnology
b) Probability, Microbiology
c) Distributions, Physics
d) Statistics, Probability, Distributions
View Answer

Answer: d
Explanation: R has many functions for all types of mathematical objects. For example,
Statistics, Probability, Distributions like Multivariate, Continuous, Simple, Discrete etc.

Check this: Programming MCQs | Information Technology Books

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.

8. Which is simpler for statistical programming?


a) C
b) Java
c) R
d) No language
View Answer

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.

9. A _______________ is a variable that holds one value at a time.


a) Scalar variable
b) Duplex
c) High
d) Vector
View Answer

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

1. In 1991, R was created by Ross Ihaka and Robert Gentleman in the


Department of Statistics at the University of _________
a) John Hopkins
b) California
c) Harvard
d) Auckland
View Answer
Answer: d
2. Finally, in _________ R version 1.0.0 was released to the public.
a) 2000
b) 2005
c) 2010
d) 2012
View Answer
Answer: a
3. R is technically much closer to the Scheme language than it is to the
original _____ language.
a) B
b) C
c) C++
d) S
View Answer
Answer: d

4. Version of R released to the public in 2000 was_________


a) 1.0.0
b) 1.0.3
c) 2.0.1
d) 1.1.0
View Answer
Answer: a
5. The primary source code copyright for R is held by the ___________
a) R Foundation
b) S Foundation
c) R and S foundation
d) C Foundation
View Answer
Answer: a

6. R is published under the __________ General Public License version.


a) A
b) B
c) C
d) GNU
View Answer
Answer: d

7. Which of the following packages does not contain in “base” R system?


a) utils, graphics
b) mesh, compiler
c) splines, stats4
d) grDevices, datasets
View Answer
Answer: b

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

9. Which of the following command is used to print an object “x” in R?


a) printf(x)
b) print(x)
c) printx
d) print[x]
View Answer
Answer: b
10. R functionality is divided into a number of ________
a) Packages
b) Functions
c) Domains
d) Classes
View Answer
Answer: a

11. Which Package contains most fundamental functions to run R?


a) root
b) child
c) base
d) parent
View Answer
Answer: c

12 Point out the wrong statement?


a) One nice feature that R shares with many popular open source projects is
frequent releases
b) R has sophisticated graphics capabilities
c) S’s base graphics system allows for very fine control over essentially every
aspect of a plot or graph
d) All of the mentioned
View Answer
Answer: c
Explanation: R has maintained the original S philosophy, which is that it
provides a language that is both useful for interactive work, but contains a
powerful programming language for developing new tools.

13. Which of the following is a base package for R language?


a) util
b) lang
c) tools
d) spatial
View Answer
Answer: c

14. Which of the following is “Recommended” package in R?


a) util
b) lang
c) stats
d) spatial
View Answer
Answer: d
15. What is the output of getOption(“defaultPackages”) in R studio?
a) Installs a new package
b) Shows default packages in R
c) Error
d) Nothing will print
View Answer
Answer: b

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

17. Which of the following is used for Statistical analysis in R language?


a) RStudio
b) Studio
c) Heck
d) KStudio
View Answer
Answer: a

18. What will be the output of the following R program?

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.

19. Which of the following operator is used to create integer sequences?


a) :
b) ;
c) –
d) ~
View Answer
Answer: a

20. What will be the output of the following R program?

y<-0:5
vector(y)
y[3]

a) Error in vector(y): invalid ‘mode’ argument


b) 1
c) 4
d) 3
View Answer
Answer: a
Explanation: y is already vector; second line is an invalid argument. The third
line will give us the output. When an R vector is printed you will notice that
an index for the vector is printed in square brackets
[] on the side.

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

22. A list is represented as a vector but can contain objects of ___________


a) Same class
b) Different class
c) Similar class
d) Any class
View Answer
Answer: b
Explanation: A list can contain objects of different class. But a vector can only
contain objects of the same class. A vector cannot have contain objects of the
different class. Same class objects are used mostly.

23. How can we define ‘undefined value’ in R language?


a) Inf
b) Sup
c) Und
d) NaN
View Answer
Answer: d

24. What is NaN called?


a) Not a Number
b) Not a Numeric
c) Number and Number
d) Number a Numeric
View Answer
Answer: a
25. How can we define ‘infinity’ in R language?
a) Inf
b) Sup
c) Und
d) NaN
View Answer
Answer: a

26. What will be the output of the following R code?

y <- c(TRUE, 2)

a) [1] “TRUE” “2”


b) [1] “TRUE” 2
c) [1] “0” “2”
d) [1] 1 2
View Answer
Answer: d

27. What is the class defined by the following R code?

y<-c(2,”t”)

a) Character
b) Numeric
c) Logical
d) Integer
View Answer
Answer: a

28. What is the class defined in the following R code?


y<-c(FALSE,2)

a) Character
b) Numeric
c) Logical
d) Integer
View Answer
Answer: b

29. Which one of the following is not a basic datatype?


a) Numeric
b) Character
c) Data frame
d) Integer
View Answer
Answer: c

30. How do you create an integer suppose 5 in R?


a) 5L
b) 5l
c) 5i
d) 5d
View Answer
Answer: a
Explanation: To create an integer L should be added to the integer. L is added
to specify that it is an integer. An integer can also be created with many
types. If you explicitly want an integer, you need to specify the L suffix.

31. What will be the output of the following R code?

x<- c (“a”,” b”)


as.numeric(x)

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

32. The dimension attribute is itself an integer vector of length _______


a) 1
b) 2
c) 3
d) 4
View Answer
Answer: b

33. How could be the matrix constructed by using the following R code?

m <- matrix(1:6, nrow = 2, ncol = 3)

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

37. What is the function to set column names for a matrix?


a) names()
b) colnames()
c) col.names()
d) column name cannot be set for a matrix
Answer: b
38. The most convenient way to use R is at a graphics workstation running a
________ system.
a) windowing
b) running
c) interfacing
d) matrix
View Answer
Answer: a

39. 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
Answer: b
Explanation: help command is used for knowing details of particular
command in R.

40. Which of the following is default prompt for UNIX environment?


a) >
b) >>
c) <
d) <<
View Answer
Answer: a

41. Which of the following will start the R program?


a) $ R
b) > R
c) * R
d) @ R
View Answer
Answer: a
Explanation: At this point R commands may be issued.
42. Point out the wrong statement?
a) Windows versions of R have other optional help system also
b) The help.search command (alternatively ??) allows searching for help in
various ways
c) R is case insensitive as are most UNIX based packages, so A and a are
different symbols and would refer to different variables
d) $ R is used to start the R program
View Answer
Answer: c

43. Which of the following statement is alternative to _________

?solve

a) help(solve)
b) print(solve)
c) bind(solve)
d) matrix(solve)
View Answer
Answer: a

44. Elementary commands in R consist of either _______ or assignments.


a) utilstats
b) language
c) expressions
d) packages
View Answer
Answer: c

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.

48. What is output of getOption(“defaultPackages”) in R studio?


a) Installs a new package
b) Shows default packages in R
c) Error
d) Nothing will print
View Answer
Answer: b

49 R language has superficial similarity with _________


a) C
b) Python
c) MATLAB
d) SAS
View Answer
Answer: a

50. What is the mode of ‘a’ in the following R code?

a <- c(1,” a”, FALSE)

a) Numeric
b) Character
c) Integer
d) Logical
View Answer
Answer: b

51. What is the length of 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

53. How many atomic vector types does R have?


a) 5
b) 6
c) 8
d) 10
View Answer
Answer: b
54. 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

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

56. R has many functions regarding ________________


a) Statistics, Biotechnology
b) Probability, Microbiology
c) Distributions, Physics
d) Statistics, Probability, Distributions
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

58. Which function is used to automatically vectorize?


a) lapply()
b) kapply()
c) mapply()
d) happly()
View Answer
answer: c

59. . A _______________ is a variable that holds one value at a time.


a) Scalar variable
b) Duplex
c) High
d) Vector
View Answer
Answer: a

60. Point out the wrong statement?


a) The grammar of the language determines whether an expression is
complete or not
b) The <- symbol is the assignment operator in R
c) The ## character indicates a comment
d) R does not support multi-line comments or comment blocks
View Answer
Answer: c

61. Files containing R scripts ends with extension ____________


a) .S
b) .R
c) .Rp
d) .SP
View Answer
Answer: b

62. Point out the wrong statement?


a) : operator is used to create integer sequences
b) The numbers in the square brackets are part of the vector itself
c) There is a difference between the actual R object and the manner in which
that R object is printed to the console
d) Files containing R scripts ends with extension .R
View Answer
Answer: b
Explanation: They are merely part of the printed output.
63. If commands are stored in an external file, say commands.R in the
working directory work, they may be executed at any time in an R session
with the command ____________
a) source(“commands.R”)
b) exec(“commands.R”)
c) execute(“commands.R”)
d) exect(“command.R”)
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

67. Collection of objects currently stored in R is called as ________________


a) package
b) workspace
c) list
d) task
View Answer
Answer: b

68. What is the meaning of the following R function?

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

69. What is the meaning of the following R function?

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

a) Prints todays date


b) Prints some date
c) Prints exact present time and date
d) Error
View Answer
Answer: c

71 What will be the output of the following R function?

paste("Everybody", "is", “a” , "warrior")

a) “Everybody”, “is”, “a” , “warrior”


b) Everybody is a warrior
c) Everybody”, “is”, “a” , “warrior
d) “Everybody is a warrior”
View Answer
Answer: d
Explanation: Both paste() and cat() print out text to the console by combining
multiple character vectors together, it is impossible for those functions to
know in advance how many character vectors will be passed to the function
by the user.

72. What will be the output of the following R function?

cat("Everybody", "is", "a", “warrior”,sep="*")

a) “Everybody”, “is”, “a” , “warrior”


b) Everybody*is*a*warrior
c) Everybody”, “is”, “a” , “warrior
d) “Everybody*is*a*warrior”
View Answer
Answer: b

73. What will be the output of the following R function?

nchar()

a) no. of characters
b) first 5 characters
c) last 5 characters
d) Does not exist
View Answer
Answer: a

74 What will be the output of the following R function?

Sys.Date()

a) Tomorrow date
b) Present date
c) Some date
d) Yesterday date
View Answer
Answer: b

75. What will be the output of the following R function?

Sys.time()

a) Tomorrow date and time


b) Present date and time
c) Some date
d) Yesterday date and time
View Answer
Answer: b

76. Numbers in R are generally treated as _______ precision real numbers.


a) single
b) double
c) real
d) imaginary
View Answer
Answer: b

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

78. Point out the correct statement?


a) The value NaN represents undefined value
b) Number Inf represents infinity in R
c) NaN can also be thought of as a missing value
d) “raw” objects are commonly used directly in data analysis
View Answer
Answer: b

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

81. Which of the following can be considered as object attribute?


a) dimensions
b) class
c) length
d) all of the mentioned
View Answer
Answer: d

82. What will be the output of the following R code?

> x <- vector("numeric", length = 10)


> x

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

84. Which of the following statement is invalid?


a) x <- c(1+0i, 2+4i)
b) x <- c(TRUE, FALSE)
c) x <- c(T, F)
d) None of the mentioned
View Answer
Answer: d

85. . Point out the correct statement?


a) Use explicit TRUE and FALSE values when indicating logical values
b) rm command is used to remove objects in R
c) R operates on named data structures
d) All of the mentioned
View Answer
Answer: d

86. What will be the output of the following R code?

> x <- 6
> class(x)

a) “integer”
b) “numeric”
c) “real”
d) “imaginary”
View Answer
Answer: b

87.. What will be the output of the following R code?

> x <- 0:6


> as.logical(x)

a) FALSE TRUE TRUE TRUE TRUE TRUE TRUE


b) “0” “1” “2” “3” “4” “5” “6”
c) 0 1 2 3 4 5 6
d) 6 5 5 3 2 1
View Answer
Answer: a
88. Point out the correct statement?
a) The usual operator, <-, can be thought of as a syntactic shortcut to
expression operation
b) Assignment can also be made using the function assignment()
c) Vectors can be used in arithmetic expressions, in which case the
operations are performed element by element
d) seq() is used to delete the numbers
View Answer
Answer: c

89. What will be the output of the following R code?

> 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.

90. Which of the following code constructs vector of length 11?


a)

> v <- 3*x + y + 1

b)

> v <- 3*x + y + 2

c)

> v <- 2*x + y + 1

d)

> v <- 2*x + y + 4


View Answer
Answer: c

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

92. Which of the following is used for generating sequences?


a) seq()
b) sequence()
c) order()
d) orderasc()
View Answer
Answer: a

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

> x <- 0:6

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

95. What will be the output of the following R code?

x <- c("a", "b", "c")


> as.numeric(x)

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?

> x <- c("a", "b", "c")


> as.logical(x)

a) a b c
b) NA NA NA
c) 0 1 2
d) 6 8 9
View Answer
Answer: b

97. Point out the correct statement?


a) The elements of a logical vector cannot have the values TRUE, FALSE, and
NA
b) Matrices are vectors with a dimension attribute
c) Numerical vectors are generated by conditions
d) seq() function has four arguments
View Answer
Answer: b

98. Which of the following is invalid assignment?


a)

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

b)

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

c)

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

d)

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

View Answer
Answer: a

99. What will be the output of the following R code?

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


> dim(m)

a) 3 2
b) 2 3
c) 2 2
d) 4 5
View Answer
Answer: b
Explanation: Matrices are constructed column-wise.

100. What will be the output of the following R code?

> m <- 1:10


> m

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?

> x <- 1:3


> y <- 10:12
> cbind(x, y)

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

102. Find the following type of vector?

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

107. An ordered collection of objects or components are called ________


a) Data frames
b) Datasets
c) Databases
d) Lists
View Answer
Answer: d

108. An ordered collection of objects or components are called ________


a) Data frames
b) Datasets
c) Databases
d) Lists
View Answer
Answer: d

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

110. An ordered factor is used to represent an __________


a) Ordinal variable
b) Simple variable
c) Coordinal variable
d) Biordinal variable
View Answer
Answer: a
111. 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
View Answer
Answer: c
Explanation: 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.
112. The data type of the R-object becomes the data type of the ________
a) Functions
b) Packages
c) Variables
d) Lists
View Answer
Answer: c

113. Which function is used to combine the elements into a vector?


a) C()
b) D()
c) E()
d) F()
View Answer
Answer: a

114. A __________ is an R-object which can contain many different types of


elements inside it.
a) Vector
b) Lists
c) Matrix
d) Functions
View Answer
Answer: b

115. A _________ is a two-dimensional rectangular data set.


a) Vector
b) Lists
c) Matrix
d) Functions
View Answer
Answer: c

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

118. Factors are created using the _______ function.


a) C()
b) Function()
c) Array()
d) Lists()
View Answer
Answer: b

119. By what function we can create data frames?


a) Data.frames()
b) Data.sets ()
c) Function ()
d) C ()
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

121. Lists can be coerced with which function?


a) As.lists
b) Has.lists
c) In.lists
d) Co.lists
View Answer
Answer: a

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

123. Data frames can have additional attributes such as __________


a) Rowname()
b) Rownames()
c) R.names()
d) D.names()
View Answer
Answer: b

124. Decimal values are referred as ________ data types in R.


a) Numeric
b) Character
c) Integer
d) Lists
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

129. What is the simplest way of creating the vector?


a) C function
b) Create
c) Destroy
d) Invalid
View Answer
Answer: a

130. Which function replicates elements of vectors?


a) C
b) Rep
c) Crep
d) Grep
View Answer
Answer: b

131. The ________ function creates a regular sequence of values to form a


vector.
a) sequel
b) Rep
c) seq
d) Grep
View Answer
Answer: c
132. Which function is used to enter in data at the terminal?
a) Scanned
b) Scnn
c) Scan
d) Sccn
View Answer
Answer: c

133. Computation with vectors is achieved using an element-by-element


operation for avoiding _________
a) Loops
b) Functions
c) Packages
d) Interfaces
View Answer
Answer: a

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

135. Which dimension corresponds to the explanatory variables collected for


each species?
a) First
b) Second
c) Third
d) Fifth
View Answer
Answer: b

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

140. Lists can be created using the _______ function.


a) Matrix.li
b) Matrix.lists
c) Lists.matric
d) List
View Answer
Answer: d

141. First component of the list can be accessed by _____________


a) Name of the component
b) List name
c) Function
d) Package
View Answer
Answer: a

142. The first component can be accessed using __________ operator.


a) Intraction
b) Extraction
c) AND
d) OR
View Answer
Answer: b

143. To extract a sublist, we use _________ brackets.


a) Flower
b) Square
c) Double
d) Single
Answer: d
144. The length of a list is ______ to the number of components in that list.
a) Double
b) Equal
c) Triple
d) One fourth
View Answer
Answer: b

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

147. Which function gives the list as output?


a) Spline
b) Matrix
c) Vector
d) Alphabet
View Answer
Answer: a

148. Density function gives output as ________


a) Matrix
b) Lists
c) Vector
d) Number
View Answer
Answer: b
149. Locator function gives output as ___________
a) Matrix
b) Lists
c) Vector
d) Number
View Answer
Answer: b

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

151. Which of the following is used for reading in saved workspaces?


a) unserialize
b) load
c) get
d) set
View Answer
Answer: b
152. Point out the wrong statement?
a) write.table is used for for writing tabular data to text files (i.e. CSV) or
connections
b) writeLines is used for for writing character data line-by-line to a file or
connection
c) dump is used for for dumping a textual representation of multiple R objects
d) all of the mentioned
View Answer
Answer: d

153. ________ is used for outputting a textual representation of an R object.


a) dput
b) dump
c) dget
d) dset
View Answer
Answer: a
154. Which of the following argument denotes if the file has a header line?
a) header
b) sep
c) file
d) footer
View Answer
Answer: a

155. Point out the correct statement?


a) unserialize is used for converting an R object into a binary format for
outputting to a connection
b) save is used for saving an arbitrary number of R objects in binary format to
a file
c) The read.data() function is one of the most commonly used functions for
reading data
d) save is not used for saving an arbitrary
View Answer
Answer: b

156. Which of the following statement would read file “foo.txt”?


a) data <- read.table(“foo.txt”)
b) read.data <- read.table(“foo.txt”)
c) data <- read.data(“foo.txt”)
d) data <- data(“foo.txt”)
View Answer
Answer: a

157. Which of the following function is identical to read .table?


a) read.csv
b) read.data
c) read.tab
d) read.del
View Answer
Answer: a

158. Which of the following code would read 100 rows?


a) initial <- read.table(“datatable.txt”, nrows = 100)
b) tabAll <- read.table(“datatable.txt”, colClasses = classes)
c) initial <- read.table(“datatable.txt”, nrows = 99)
d) initial <- read.table(“datatable.txt”, nrows = 101)
View Answer
Answer: a
159. Which of the following is used for reading tabular data?
> y <- data.frame(a = 1, b = "a")
> dput(y, file = "y.R")
> new.y <- dget("y.R")
> new.y

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

163. We can dump() R objects to a file by passing _____


a) character vector of their names
b) object name
c) arguments
d) file name
View Answer
Answer: a

164. If we want to save individual R objects to a file, we use the _______


function.
a) save()
b) save.image()
c) serialize()
d) deserialize()
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

169. load() is used for _______


a) reading
b) loading
c) working
d) not exist
View Answer
Answer: a

170. readlines is used for ____________


a) working on data
b) reading files
c) reading lines in files
d) not exist
View Answer
Answer: b

171. Which of the following R statement will save the output to the file for
following R code?

> a <- data.frame(x = rnorm(100), y = runif(100))


> b <- c(3, 4.4, 1 / 3)

a) save(a, b, file = “mydata.rda”)


b) save_image(a, b, file = “mydata.rda”)
c) keep(a, b, file = “mydata.rda”)
d) keep_image(a, b, file = “mydata.rda”)
View Answer
Answer: a

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

173. 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 format
View Answer
Answer: a

175. ________ opens a connection to a file compressed with gzip.


a) url
b) gzfile
c) bzfile
d) file
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

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


a) con <- file(“foo.txt”)
b) open(con, “r”)
c) opencon(con, “r”)
d) ocon(con, “r”)
View Answer
Answer: a

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

179. Which of the following opens connection to gz-compressed text file?


a) con <- gzfiles(“words.gz”)
b) con <- gzfile(“words.gz”)
c) con <- gzfile2(“words.gz”)
d) con <- gzfiles2(“words.gz”)
View Answer
Answer: b

180. Which of the following extracts first element from the following R vector?

> x <- c("a", "b", "c", "c", "d", "a")

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

183. What will be the output of the following R code?

> x <- c("a", "b", "c", "c", "d", "a")


> x[c(1, 3, 4)]

a) “a” “b” “c”


b) “a” “c” “c”
c) “a” “c” “b”
d) “b” “c” “b”
View Answer
Answer: b

184. Point out the wrong statement?


a) $ operator semantics are similar to that of [[
b) The [ operator always returns an object of the same class as the original
c) The $ operator is used to extract elements of a list or a data frame
d) There are three operators that can be used to extract subsets of R objects
View Answer
Answer: c

185. What will be the output of the following R code?

> x <- matrix(1:6, 2, 3)


> x[1, 2]

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?

> x <- matrix(1:6, 2, 3)


a) x[2, ]
b) x[1, 2]
c) x[, 2]
d) x[1 1 2]
View Answer
Answer: c

187. What will be the output of the following R code?

> x <- matrix(1:6, 2, 3)


> x[1, , drop = FALSE]

a)

[,1] [,2] [,3]


[1,] 1 3 5

b)

[,1] [,2] [,3]


[1,] 2 3 5

c)

[,1] [,2] [,3]


[1,] 1 2 5

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.

189. What will be the output of the following R code?

> x <- list(foo = 1:4, bar = 0.6)


> x

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?

> x <- list(a = list(10, 12, 14), b = c(3.14, 2.81))

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

191. Which of the following is example of vectorized operation as far as


subtraction is concerned?

> x <- 1:4


> y <- 6:9

a) x+y
b) x-y
c) x/y
d) x–y
View Answer
Answer: b

192. Point out the wrong statement?


a) Very less operations in R are vectorized
b) Vectorization allows you to write code that is efficient, concise, and easier
to read than in non-vectorized languages
c) vectorized means that operations occur in parallel in certain R objects
d) Matrix operations are also vectorized
View Answer
Answer: a
193. What will be the output of the following R code?

> x <- 1:4


> y <- 6:9
> z <- x + y
> z

a) 7 9 11 13
b) 7 9 11 13 14
c) 9 7 11 13
d) NULL
View Answer
Answer: a

194. What will be the output of the following R code?

> x <- 1:4


> x > 2

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?

> x <- 1:4


> y <- 6:9
> x/y

a) 0.1666667 0.2857143 0.4444444


b) 0.1666667 0.2857143 0.3750000 0.4444444
c) 0.2857143 0.3750000 0.4444444
d) Error
View Answer
Answer: b

196. What will be the output of the following R code?

> x <- matrix(1:4, 2, 2)


> y <- matrix(rep(10, 4), 2, 2)
> x * y
a)

[,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

197. Which of the following code represents internal representation of a Date


object?
a) class(as.Date(“1970-01-02”))
b) unclass(as.Date(“1970-01-02”))
c) unclassint(as.Date(“1970-01-02”))
d) classint(as.Date(“1970-02-02”))
View Answer
Answer: b
Explanation: You can see the internal representation of a Date object by
using the unclass() function.

198. What will be the output of the following R code?

> x <- as.Date("1970-01-01")


> x

a) “1970-01-01”
b) “1970-01-02”
c) “1970-02-01”
d) “1970-02-02”
View Answer
Answer: a

199. What will be the output of the following R code?


> x <- Sys.time()
> class(x)

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

202. What will be the output of the following R code?

> x <- as.Date("2012-03-01")


> y <- as.Date("2012-02-28")
> x-y

a) Time difference of 3 days


b) Time difference of 2 days
c) Time difference of 1 days
d) Time difference of 5 days
View Answer
Answer: b

203. What will be the output of the following R code?

> x <- as.POSIXct("2012-10-25 01:00:00")


> y <- as.POSIXct("2012-10-25 06:00:00", tz = "GMT")
> y-x
a) Time difference of 1 hour
b) Time difference of 1 min
c) Time difference of 1 sec
d) Time difference of 5 sec
View Answer
Answer: a

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

205. 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 mentioned
View Answer
Answer: d

206. . _________ extract a subset of rows from a dataframe based on logical


conditions.
a) rename
b) filter
c) set
d) subset
View Answer
Answer: a

207. _________ generate summary statistics of different variables in the data


frame, possibly within strata.
a) rename
b) summarize
c) set
d) subset
View Answer
Answer: b
208. ________ add new variables/columns or transform existing variables.
a) mutate
b) add
c) apped
d) arrange
View Answer
Answer: a
Explanation: arrange is used to reorder rows of a dataframe.

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

211. Which of the following object is masked from ‘package: stats’?


a) filter
b) union
c) set difference
d) get difference
View Answer
Answer: a
Explanation: The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union.

212. ________ function is similar to the existing subset() function in R but is


quite a bit faster.
a) rename
b) filter
c) set
d) subset
View Answer
Answer: b
213. Columns can be arranged in descending order too by using the special
____ operator.
a) asc()
b) desc()
c) descending()
d) subset
View Answer
Answer: b

214. . 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 R
View Answer
Answer: c

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

216. The ______ operator allows you to string operations in a left-to-right


fashion.
a) %>%>
b) %>%
c) >%>%
d) >>>>%%%
View Answer
Answer: b

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

219. Which of the following function is similar to summarize?


a) arrange_by()
b) group()
c) group_by()
d) arrange
View Answer
Answer: c

220. Which of the following involves predicting a categorical response?


a) Regression
b) Summarization
c) Clustering
d) Classification
View Answer
Answer: d
Explanation: Classification techniques are widely used in data mining to
classify data.

221. ______ is simplest class of analytics.


a) Descriptive
b) Predictive
c) Prescriptive
d) Summarization
View Answer
Answer: a
Explanation: Descriptive is the simplest class of analytics. Predictive analytics
can only forecast what might happen in the future because all predictive
analytics are probabilistic in nature.

222. __________ is proprietary tool for predictive analytics.


a) R
b) SAS
c) SSAS
d) EDR
View Answer
Answer: b
223. _________ involves predicting a response with meaningful magnitude,
such as quantity sold, stock price, or return on investment.
a) Regression
b) Summarization
c) Clustering
d) Classification
View Answer
Answer: a
Explanation: Regression and classification are two common types predictive
models.

224. Which of the following is used to plot multiple histograms?


a) multi.plot()
b) multi.hist
c) xyplot.multi()
d) poly()
View Answer
Answer: b
225. Which of the following gives the summary of values likes mean etc?
a) mean
b) sd
c) describe
d) lm
View Answer
Answer: c

226. The purpose of correct.cor is to correct _________ in values.


a) difference
b) reliability
c) error
d) similar
View Answer
Answer: b

227. What plot(s) are used to view the linear regression?


a) Scatterplot
b) Box plot
c) Density plot
d) Scatterplot, Boxplot, Density plot
View Answer
Answer: d
Explanation: Each plot has its own importance of highlighting a specific
feature. Scatter plot is used to visualise the relationship between the
variables, Box plot is used to spot the outliers which effect line of best fit.
228. Common Metrics which are used to select linear model are ____________
a)

R-Squared Lower the better

F-Statistic Higher the better

b)

R-Squared Lower the better

F-Statistic Lower the better

c)

R-Squared Higher the better

F-Statistic Higher the better

d)

R-Squared Higher the better

F-Statistic Lower the better

View Answer
Answer: c

229. In lm(response ~ terms), terms specification of the form “first*second” is


same as __________
a) first+second
b) first:second
c) first+second+first:second
d) first:second+second:first
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

ii) Adjusted R Squared

iii) F Statistics

iv) RMSE / MSE / MAE

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.

235. Function used for linear regression in R is __________


a) lm(formula, data)
b) lr(formula, data)
c) lrm(formula, data)
d) regression.linear(formula, data)
View Answer
Answer: a

236. n syntax of linear model lm(formula,data,..), data refers to ______


a) Matrix
b) Vector
c) Array
d) List
View Answer
Answer: b

237. In the mathematical Equation of Linear Regression Y = β1 + β2X + ϵ,


(β1, β2) refers to __________
a) (X-intercept, Slope)
b) (Slope, X-Intercept)
c) (Y-Intercept, Slope)
d) (slope, Y-Intercept)
View Answer
Answer: c
Explanation: Y-intercept is β1 and X-intercept is – (β1 / β2). Intercepts are
defined for axis and formed when the coordinates are on the axis.

238The square of the correlation coefficient r 2 will always be positive and is


called the ________
a) Regression
b) Coefficient of determination
c) KNN
d) Algorithm
View Answer
Answer: b

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.

You might also like