is_copyable

0th

Percentile

Is an object copyable?

When an object is modified, R generally copies it (sometimes lazily) to enforce valuesemantics. However, some internal types are uncopyable. If you try to copy them, either with <- or by argument passing, you actually create references to the original object rather than actual copies. Modifying these references can thus have far reaching side effects.

Usage
is_copyable(x)
Arguments
x

An object to test.

• is_copyable
Examples
library(rlang) # NOT RUN { # Let's add attributes with structure() to uncopyable types. Since # they are not copied, the attributes are changed in place: env <- env() structure(env, foo = "bar") env # These objects that can only be changed with side effect are not # copyable: is_copyable(env) structure(base::list, foo = "bar") str(base::list) # } 
Documentation reproduced from package rlang, version 0.2.0, License: GPL-3

Community examples

Looks like there are no examples yet.