64.
What will be the output of the following R code?
> x <- 1:4
> lapply(x, runif)

[[1]]
[1] 0.02778712
[[2]]
[1] 0.5273108 0.8803191
[[3]]
[1] 0.37306337 0.04795913 0.13862825
[[4]]
[1] 0.3214921 0.1548316 0.1322282 0.2213059

[[1]]
[1] 1.02778712
[[2]]
[1] 2.5273108 0.8803191
[[3]]
[1] 3.37306337 0.04795913 0.13862825
[[4]]
[1] 0.3214921 0.1548316 0.1322282 0.2213059

[[1]]
[1] 1.02778712
[[2]]
[1] 0.5273108 0.8803191
[[3]]
[1] 0.37306337 0.04795913 0.13862825
[[4]]
[1] 3.3214921 2.1548316 1.1322282 0.2213059

65.
What will be the output of the following R code?
> x <- c("a", "b", "c", "d")
> for(i in 1:4) {
    + ## Print out each element of 'x'
    + print(x[i])
+ }

67.
What will be the output of the following R code?
> x <- list(a = 1:5, b = rnorm(10))
> lapply(x, mean)

68.
Which of the following R code syntax is syntactically valid?

if ( statement1 ) {
    statement2
} else if ( statement3 ) {
    statement4
} else if ( statement5 ) {
    statement6
} else
    statement8

if ( statement1 ) {
    statement2
} elseif ( statement3 ) {
    statement4
} elseif ( statement5 ) {
    statement6
} else
    statement8

if ( statement1 ) {
    statement2
} elseif ( statement3 ) {
    statement4
} else if ( statement5 ) {
    statement6
} else
    statement8

if ( statement1 ) {
    statement2
} else if ( statement5 ) {
    statement6
} else
    statement8

Read More Section(Control Structures in R Programming)

Each Section contains maximum 100 MCQs question on Control Structures in R Programming. To get more questions visit other sections.