Questions tagged [vctrs]

Use this tag to questions related to vctrs (a developer-focused package for R).

41 questions
14
votes
5 answers

tidyverse not loaded, it says "namespace ‘vctrs’ 0.2.0 is already loaded, but >= 0.2.1 is required"

strong textI keep encountering problems with installing tidyverse package, which preventing me from implementing many text processing tasks. The problem is the same as those mentioned in many previous threads since 2017 in that when I enter…
Chris T.
  • 1,699
  • 7
  • 23
  • 45
7
votes
1 answer

`vec_arith` not called as expected

I lay a simple case below where I define a class "foo" over a double object, I want any arithmetic operation involving such object to strip it of its "foo" class and proceed normally. I can partially make it work, but not robustly. see below…
moodymudskipper
  • 46,417
  • 11
  • 121
  • 167
4
votes
1 answer

Implementing a parallel attribute vctrs class

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…
teunbrand
  • 33,645
  • 4
  • 37
  • 63
4
votes
2 answers

Does dplyr::mutate work with record-style columns?

I've been testing out the vctrs package recently, especially what they call "record-style" objects recently, and I'm wondering if there's any way to get them to play nice with dplyr::mutate. Currently, when dplyr::mutate gives me an error about the…
Paul PR
  • 168
  • 10
4
votes
0 answers

Constructor for empty grouped data frame/tibble in dplyr

Would you know a way to construct an empty grouped data.frame or tibble in dplyr? This is the best that I could come up with for a constructor of a custom grouped_df class, but I don't like it as the result in fact isn't a true…
Rappster
  • 12,762
  • 7
  • 71
  • 120
3
votes
1 answer

How can I make a {vctrs} S3 class error on arithmetic with base S3 classes?

Working through 'Arithmetic' in vignette("s3-vector", "vctrs") to create my own class, I've hit some undesirable behaviour and I'm struggling to see how to address it. My issue is that arithmetic with my class and a base-R class actually works when…
wurli
  • 2,314
  • 10
  • 17
3
votes
4 answers

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

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…
Andrew Hill
  • 307
  • 2
  • 12
3
votes
0 answers

Understanding [<-, [[<-, and vec_c for vctrs list_of

Asking question that I asked on the RStudio community forums in case anyone is able to provide assistance here. Hello everyone, I am trying to better understand the behavior of [<-, [[<-, vec_c, and c for list_of classes. I am defining a list_of…
caldwellst
  • 5,719
  • 6
  • 22
2
votes
0 answers

dplyr::bind_rows throws error 'error in vec_size' when binding tribbles

Binding two tribbles library(tidyverse) dplyr::tribble( ~comp, ~val, "g", 100 ) %>% dplyr::bind_rows( dplyr::tribble( ~comp, ~val, "h", 100 ) ) results in the following error Error in `vec_size()`: ! `x` must be a…
tomw
  • 3,114
  • 4
  • 29
  • 51
2
votes
2 answers

R vctrs subclassing with unicity constraint

In R, I need to define a subclass of vctrs with an unicity constraint. I can propose here a minimal code for such new uid vector type. library(vctrs) new_uid <- function(x) { if (anyDuplicated(x) > 0) stop("Duplicated id") …
2
votes
0 answers

Double dispatch in R: S4 vs vctrs library

If we want to implement a double dispatch method in R, we currently have two options to choose from: S4 methods vctrs library S3-based double dispatch I especially mean arithmetic operators, such as + or *. How do they compare in terms of…
KrzJoa
  • 71
  • 2
  • 4
2
votes
1 answer

Using vctrs in matrices

I'm experimenting with the vctrs package. My actual use-case is in relevant aspects similar to the rational class implemented in the helpful S3 vectors article on the vctrs homepage, in that it uses rcrd for paired data. I'll use that for my reprex…
MSR
  • 2,731
  • 1
  • 14
  • 24
1
vote
1 answer

Optimize repeated fisher test over dataframe

I have a code segment that I am trying to optimize to run a bit faster. df1 <- df %>% rowwise() %>% mutate(fisher = fisher.test(matrix(c(counts, nt1_not_t2, nt2_not_t1, not_t1_or_t2), nrow = 2, ncol =…
Dave R
  • 202
  • 1
  • 8
1
vote
0 answers

vctrs::vec_chop method to replace filter(row_number() == 1)

I'm working on trying to improve my code by using the tips outlined in this recent blog post https://www.tidyverse.org/blog/2023/04/performant-packages/ . I've managed to replace some of my simpler filter and mutate calls for slightly speedier…
Dave R
  • 202
  • 1
  • 8
1
vote
0 answers

DLL VCTRS not found when loading ggplot2

I use R 4.1.3. My problem is that after I installed ggplot2, I try to load the package by typing library(ggplot2), however the following message comes up: Error: package or namespace load failed for ‘ggplot2’ in library.dynam(lib, package,…
Lakrids
  • 11
  • 2
1
2 3