Control Structures In R Programming - Study Mode
[#131] Which of the following R code will print the following result? [[1]]
[1] 2.263808
[[2]]
[1] 1.314165 9.815635
[[3]]
[1] 3.270137 5.069395 6.814425
[[4]]
[1] 0.9916910 1.1890256 0.5043966 9.2925392
Correct Answer
(A) > x <- 1:4 > lapply(x, runif, min = 0, max = 10)
[#132] What will be the output of the following R code? > f <- function(num) {
+ hello <- "Hello, world!
"
+ for(i in seq_len(num)) {
+ cat(hello)
+ }
+ chars <- nchar(hello) * num
+ chars
+ }
> meaningoflife <- f(3)
> print(meaningoflife)
Correct Answer
(A) 32
[#133] . . . . . . . . function is same as lapply in R.
Correct Answer
(C) sapply()
[#134] What would be the value of following R expression? log(-1)
Correct Answer
(A) Warning in log(-1): NaNs produced
[#135] The . . . . . . . . for R are the main feature that make it different from the original S language.
Correct Answer
(A) scoping rules