If you execute
x <- 1:5
"[<-"(x, 2:3, value = 9:10)
you'll see the output resulting from the substitution:
1 9 10 4 5
However, the original value x
will not be affected (you are not overwriting it)
Hence, if you execute x
, you'll see its original value:
1 2 3 4 5
If I run all the lines at the same time (I guess you're using RStudio), I'll see this (I think this is why you're asking for)
execute> x <- 1:5
execute> "[<-"(x, 2:3, value = 9:10)
[1] 1 9 10 4 5
execute> x
[1] 1 9 10 4 5
I guess this is some kind of weird RStudio behavior (maybe similar to this one), although, the value of x
is not affected at all.
Note that it doesn't happen if you change the last line. E.g.
x <- 1:5
"[<-"(x, 2:3, value = 9:10)
x <- 6:10
execute> x <- 1:5
execute> "[<-"(x, 2:3, value = 9:10)
[1] 1 9 10 4 5
execute> x <- 6:10
execute>
EDITED
Running with R version 3.3.1 and RStudio Version 0.99.467.
Running the three lines changes the value of x
to 1 9 10 4 5
. However, running the first line, and then both the second and the third, shows the right result (and the value of x
is not affected)
execute> x <- 1:5
execute> "[<-"(x, 2:3, value = 9:10)
[1] 1 9 10 4 5
execute> x
[1] 1 2 3 4 5