adplus-dvertising
frame-decoration

Question

What will be the output of the following R code?
> g <- function(x) {
+               a <- 3
+               x+a+y
+             ## 'y' is a free variable
+ }
> y <- 3
> g(2)

a.

9

b.

42

c.

8

d.

Error

Answer: (c).8

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?