Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. What will be the output of following code snippet ?

> lm <- function(x) { x * x }
> lm

a) function(x) { x * x }
b) func(x) { x * x }
c) function(x) { x / x }
d) none of the mentioned

View Answer

Answer: a [Reason:] When R tries to bind a value to a symbol, it searches through a series of environments to find the appropriate value.

2. Point out the correct statement :
a) The search list can be found by using the searchlist() function
B) The search list can be found by using the search() function
c) The global environment or the user’s workspace is always the second element of the search list
d) All of the mentioned

View Answer

Answer: b [Reason:] Base package is always the last element.

3. A function, together with an environment, makes up what is called a ______ closure.
a) formal
b) function
c) reflective
d) all of the mentioned

View Answer

Answer: b [Reason:] The function closure model can be used to create functions that “carry around” data with them.

4. Which of the variable in the following code is variable ?

> f <- function(x, y) {
+            x^2 + y / z
+ }

a) x
b) y
c) z
d) all of the mentioned

View Answer

Answer: c [Reason:] This function has 2 formal arguments x and y. In the body of the function there is another symbol z. In this case z is called a free variable.

5. Point out the wrong statement :
a) The order of the packages on the search list does not matter
b) R has separate namespaces for functions and non-functions
c) Users can configure which packages get loaded on startup so if you are writing a function
d) None of the mentioned

View Answer

Answer: a [Reason:] The order of the packages on the search list matters, particularly if there are multiple objects with the same name in different packages.

6. R uses _________ scoping⁶⁰ or static scoping.
a) reflective
b) transitive
c) lexical
d) all of the mentioned

View Answer

Answer: c [Reason:] Lexical scoping in R means that the values of free variables are searched for in the environment in which the function was defined.

7. The only environment without a parent is the ________ environment.
a) full
b) half
c) null
d) empty

View Answer

Answer: d [Reason:] Every environment has a parent environment and it is possible for an environment to have multiple “children”.

8. The ________ for R are the main feature that make it different from the original S language
a) scoping rules
b) closure rules
c) environment rules
d) all of the mentioned

View Answer

Answer: a [Reason:] This function never actually uses the argument b, so calling f(2) will not produce an error because the 2 gets positionally matched to a.

9. The _________ function is a kind of “constructor function” that can be used to construct other functions.
a) make.pow()
b) make.power()
c) keep.power()
d) none of the mentioned

View Answer

Answer: b [Reason:] Typically, a function is defined in the global environment, so that the values of free variables are just found in the user’s workspace.

10.What will be the output of following code ?

> g <- function(x) {
+             a <- 3
+             x+a+y
+          ## 'y' is a free variable
+ }
> g(2)

a) 9
b) 42
c) 8
d) Error

View Answer

Answer: d [Reason:] Object ‘y’ not found error is displayed.

Synopsis and Project Report

You can buy synopsis and project from distpub.com. Just visit https://distpub.com/product-category/projects/ and buy your university/institute project from distpub.com