vctrs

How do I build an object with the R vctrs package that can combine with c()

廉价感情. 提交于 2021-02-19 04:30:10
问题 I'm trying to understand how to build objects with vectors. I thought this was straightforwards, but then had trouble when I used c() on my object. Our object has two attributes, x and descriptor, both strings in this case (my object will have attributes with differing types). We've built a constructor, new_toy_vector. I haven't built a convenience function in this example yet. new_toy_vector <- function( x = character(), descriptor = character()) { vctrs::vec_assert(x,character()) vctrs::vec

Implementing a parallel attribute vctrs class

[亡魂溺海] 提交于 2021-02-07 19:12:11
问题 I'm trying to make a vector class using the vctrs package, that stores an expression. Mainly because I want to use it in a different vctrs vector. An expression is not a vector type, so a naive implementation of a vector expression (named vexpr here) fails. library(vctrs) expr <- scales::math_format()(1:10) new_vexpr <- function(x) { new_vctr(x, class = 'vexpr') } new_vexpr(expr) #> Error: `.data` must be a vector type. So, I thought, maybe I can implement the expression itself as an

Implementing a parallel attribute vctrs class

杀马特。学长 韩版系。学妹 提交于 2021-02-07 19:02:04
问题 I'm trying to make a vector class using the vctrs package, that stores an expression. Mainly because I want to use it in a different vctrs vector. An expression is not a vector type, so a naive implementation of a vector expression (named vexpr here) fails. library(vctrs) expr <- scales::math_format()(1:10) new_vexpr <- function(x) { new_vctr(x, class = 'vexpr') } new_vexpr(expr) #> Error: `.data` must be a vector type. So, I thought, maybe I can implement the expression itself as an