adplus-dvertising
frame-decoration

Question

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])
+ }

a.

[1] "a"
[1] "b"
[1] "c"
[1] "d"

b.

[1] "c"
[1] "b"
[1] "a"
[1] "d"

c.

[1] "d"
[1] "c"
[1] "b"
[1] "a"

d.

Error

Posted under R Programming

Answer: (a).[1] "a"
[1] "b"
[1] "c"
[1] "d"

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the following R code?