How to Change R Property Value?

In R programming language, you can use the attr() function to change the attribute values of an object. If we have a vector x with an attribute named prop, we can change its attribute value using the following code:

x <- 1:5
attr(x, "prop") <- "new value"

The above code changes the value of the property prop of x to “new value”.

bannerAds