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
Concatenating a numeric NA to a vector works, anything else does not:
library(vctrs)
new_vecreprex<-function(x=1){
new_vctr(as.list(x), class="vecreprex",
meta="very important info, must be preserved")
}
a<- new_vecreprex(2:3)
c(a, NA) |> str() #great!## vecreprx [1:3] ## $ : int 2## $ : int 3## $ : NULL## @ meta: chr "very important info, must be preserved"
c(NA, a) |> str() #fails, loses class attributes etc ## List of 3## $ : logi NA## $ : int 2## $ : int 3
c(a, NA*1) |> str() #logical NAs are ok but numerical ones are not? seems very weird....## Error in `vec_c()`:## ! Can't combine `..1` <vecreprex> and `..2` <double>.
sorry, i misread the docs. It's now clear to me that this is actually the expected behavior for c and that vec_c in contrast does what it should.
if any vctrs developers read this, an important Q the docs could maybe answer more explicitly is how to make sure that vec_c is used for concatenation instead of c as often as possible...?
Concatenating a numeric NA to a vector works, anything else does not:
see also tidyfun/tf#5
The text was updated successfully, but these errors were encountered: