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 ?

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

a) “a+b”
b) “a=b”
c) “a b :”
d) none of the mentioned

View Answer

Answer: d [Reason:] 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.

2. Point out the correct statement :
a) In R, a function is an object which has the mode function
b) R interpreter is able to pass control to the function, along with arguments that may be necessary for the function to accomplish the actions that are desired
c) Functions are also often written when code must be shared with others or the public
d) All of the mentioned

View Answer

Answer: d [Reason:] An argument list is a comma separated list of formal arguments.

3. The __________ function returns a list of all the formal arguments of a function
a) formals()
b) funct()
c) formal()
d) all of the mentioned

View Answer

Answer: a [Reason:] Functions have named arguments which can optionally have default values.

4. What will be the output of the following code ?

> f <- function(num = 1) {
+        hello <- "Hello, world!n"
+        for(i in seq_len(num)) {
+                cat(hello)
+         }
+         chars <- nchar(hello) * num
+         chars
+ }
> f()

a)

Hello, world!
[1] 14

b)

Hello, world!
[1] 15

c)

Hello, world!
[1] 16

d) All of the mentioned

View Answer

Answer: a [Reason:] The formal arguments are the arguments included in the function definition.

5. Point out the wrong statement :
a) A formal argument can be a symbol, a statement of the form ‘symbol = expression’, or the special formal argument
b) The first component of the function declaration is the keyword function
c) The value returned by the call to function is not a function
d) None of the mentioned

View Answer

Answer: a [Reason:] The value returned by the call to function is a function.

6. You can check to see whether an R object is NULL with the _________ function.
a) is.null()
b) is.nullobj()
c) null()
d) all of the mentioned

View Answer

Answer: a [Reason:] It is sometimes useful to allow an argument to take the NULL value, which might indicate that the function should take some specific action.

7. Which of the following code will print NULL ?
a) > args(paste)
b) > arg(paste)
c) > args(pastebin)
d) all of the mentioned

View Answer

Answer: a [Reason:] One catch with … is that any arguments that appear after … on the argument list must be named explicitly and cannot be partially matched or matched positionally.

8. What will be the output of following code ?

> f <- function(a, b) {
+       a^2
+ }
> f(2)

a) 4
b) 3
c) 2
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. What will be the output of following code snippet ?

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

a) “a+b”
b) “a=b”
c) “a:b”
d) none of the mentioned

View Answer

Answer: c [Reason:] 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.

10. What will be the output of following code ?

> f <- function(a, b) {
+              print(a)
+              print(b)
+ }
> f(45)

a) 32
b) 42
c) 52
d) 45

View Answer

Answer: d [Reason:] Arguments to functions are evaluated lazily, so they are evaluated only as needed in the body of the function.

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