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. ________ loop over a list and evaluate a function on each element
a) apply()
b) lapply()
c) sapply()
d) mapply()

View Answer

Answer: a [Reason:] An auxiliary function split is also useful, particularly in conjunction with lapply.

2. 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) all of the mentioned

View Answer

Answer: c [Reason:] lapply() always returns a list, regardless of the class of the input.

3. __________ function is same as lapply in R
a) apply()
b) lapply()
c) sapply()
d) mapply()

View Answer

Answer: c [Reason:] lapply tries to simplify the result.

4. Which of the following is multivariate version of lapply ?
a) apply()
b) lapply()
c) sapply()
d) mapply()

View Answer

Answer: d [Reason:] The mapply() function is a multivariate apply of sorts which applies a function in parallel over a set of arguments.

5. Point out the correct statement :
a) lapply() takes elements of the list and passes them as the first argument of the function you are applying
b) You can use lapply() to evaluate a function multiple times each with a different argument
c) Functions that you pass to lapply() may have other arguments
d) None of the mentioned

View Answer

Answer: d [Reason:] The lapply() function and its friends make heavy use of anonymous functions.

6. ________ applies a function over the margins of an array.
a) apply()
b) lapply()
c) tapply()
d) mapply()

View Answer

Answer: a [Reason:] The apply() function is used to a evaluate a function (often an anonymous one) over the margins of an array.

7. _______ is used to apply a function over subsets of a vector.
a) apply()
b) lapply()
c) tapply()
d) mapply()

View Answer

Answer: c [Reason:] t in tapply stands for table.

8. lappy functions takes _________ arguments in R language.
a) two
b) three
c) four
d) all of the mentioned

View Answer

Answer: c [Reason:] This function takes three arguments: (1) a list X; (2) a function (or the name of a function) FUN; (3) other arguments via its … argument.

9. Body of lapply function is :
a)

function (X, FUN, ...)
{
    FUN <- match.fun(FUN)
    if (!is.vector(X) || is.object(X))
       X <- as.list(X)
    .Internal(lapply(X, FUN))
}

b)

function (X, FUN, ...)
{
    FUN <- match.fun(FUN)
    if (!is.vector(X) | is.object(X))
      X <- as.list(X)
    .Internal(lapply(X, FUN))
}

c)

function (X, FUN, ...)
{
    FUN <- match.fun(FUN)
    if (is.vector(X) || is.object(X))
      X <- as.list(X)
    .Internal(lapply(X, FUN))
}

d) None of the mentioned

View Answer

Answer: a [Reason:] Actual looping is done internally in C code for efficiency reasons.

10. What will be the output of following code ?

> x <- list(a = 1:5, b = rnorm(10))
> lapply(x, mean)

a)

$a
[1] 3
$b
[1] 0.1322028

b)

$a
[1] 4
$b
[1] 0.1322028

c)

$a
[1] 5
$b
[1] 0.1322028

d) Error

View Answer

Answer: a [Reason:] If the original list has names, the the names will be preserved in the output.

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