[R] How to make a deep copy of a list?
kry|ov@r00t @end|ng |rom gm@||@com
Sat Nov 12 21:20:03 CET 2022
В Sat, 12 Nov 2022 20:04:57 +0000
Giovanni Petris <gpetris using uark.edu> пишет:
> The problem is that the C code modifies elements of the list so that,
> after the R function returns, I end up with a modified version of the
> list argument. I believe passing to the function a deep copy of the
> list argument would solve my problem.
Is it an option to change the C code? I think that the fault lies with
it, not with its caller. Except when using reference types, it should
be safe to make the assumption that variables in R are passed as if by
In the interest of getting a quick workaround, does
unserialize(serialize(L, NULL)) help? I would expect that to work unless
your list contains something like environments.
More information about the R-help