What Will Be The Output Of The Following R Codep Pre Langrsplus #342
What will be the output of the following R code?</p> <pre><code class="language-rsplus"> > x <- c("a", "b", "c", "d") > for(i in 1:4) { + ## Print out each element of 'x' + print(x[i]) + } </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 - Control Structures - Quiz No.1.
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]) + }
[1] "a" [1] "b" [1] "c" [1] "d"
[1] "c" [1] "b" [1] "a" [1] "d"
[1] "d" [1] "c" [1] "b" [1] "a"
Error