You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
vec_assign() should not mutate values, and instead return a modified copy of the original vctr (as illustrated in the examples). But this breaks for rcrd types (or more generally, where the vec_proxy is a dataframe). In these cases, the original rcrd gets modified by vec_assign():
library(vctrs)
new_foo<-function(a, b) {
new_rcrd(list(a=a, b=b), class="foo")
}
format.foo<-function(x, ...) {
format(vec_proxy(x))
}
foo<- new_foo(a= c(1, 2), b= c(3, 4))
foo#> <foo[2]>#> #> 1 1 3#> 2 2 4# This assignment should not mutate foo:bar<- vec_assign(foo, 2, new_foo(a=9000, b=9000))
foo# yikes, foo was mutated! spooky action at a distance!#> <foo[2]>#> #> 1 1 3#> 2 9000 9000
vec_assign()
should not mutate values, and instead return a modified copy of the original vctr (as illustrated in the examples). But this breaks for rcrd types (or more generally, where the vec_proxy is a dataframe). In these cases, the original rcrd gets modified byvec_assign()
:Created on 2024-08-15 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: