What Will Be The Output Of The Following R Code Snippetp Pre #381
What will be the output of the following R code snippet?</p> <pre><code class="language-rsplus"> > f <- function(num = 1) { + hello <- "Hello, world!\n" + for(i in seq_len(num)) { + cat(hello) + } + chars <- nchar(hello) * num + chars + } > f() </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs110 R Language. It can also be found in gs gs110 Control Structures, Functions, Scoping Rules, Loop Functions and Debugging - Functions - Quiz No.2.
What will be the output of the following R code snippet?
> f <- function(num = 1) { + hello <- "Hello, world!\n" + for(i in seq_len(num)) { + cat(hello) + } + chars <- nchar(hello) * num + chars + } > f()
Hello, world! [1] 14
Hello, world! [1] 15
Hello, world! [1] 16
Error