[R] There is a relationship of the Modify-in-place optimisation of a object and the local variable `*tmp*`?
Ben Deivide de Oliveira Batista
ben@de|v|de @end|ng |rom u|@j@edu@br
Fri Oct 8 00:46:52 CEST 2021
Dear R users,
When modify-in-place of objects occurs, is there a local variable called
`*tmp*`, behind the scenes R? Let's look at two examples to understand the
question.
Example 1 (R Language Definition)
--------------------------------------------------
> x <- 1:10
> tracemem(x)
[1] "<000000000798F758>"
> x[3:5] <- 13:15
tracemem[0x000000000798f758 -> 0x0000000008207030]:
The result of this command is as if the following had been executed
`*tmp*` <- x
x <- "[<-"(`*tmp*`, 3:5, value=13:15)
rm(`*tmp*`)
Conclusion: Here copy-on-modify occurs!
Example 2 : Modify-in-place
-----------------------
> x <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
> tracemem(x)
[1] "<0000000008BFB818>"
> x[3:5] <- 13:15Conclusion: Here modify-in-place occurs!
For example 2, is there a local variable `*tmp*` for this case? If so,
what would the syntactic representation look like, similar to example 1?
--
Ben Dêivide de Oliveira Batista
Prof. Estatística (DEFIM/CAP/UFSJ)
Página pessoal/profissional: bendeivide.github.io
Página Institucional: www.ufsj.edu.br/bendeivide
[[alternative HTML version deleted]]
More information about the R-help
mailing list