Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following R code?
> x < – list(foo = 1:4, bar = 0.6, baz = “hello”)
> name <- “foo”
> x[[name]]

What will be the output of the following R code?
> x < - list(foo = 1:4, bar = 0.6, baz = "hello")
> name <- "foo"
> x[[name]]
a) 1 2 3 4
b) 0 1 2 3
c) 1 2 3 4 5
d) All of the mentioned

Answer: a
Explanation: One thing that differentiates the [[ operator from the $ is that the [[ operator can be used with computed indices.

Join The Discussion