Closed jospueyo closed 6 months ago
Hmm it doesn't look like data.table
ever defines a -.data.table
method. So not sure how it retains the data.table class.
If I do this on a tibble it strips all the subclasses and just leaves a data.frame.
library(dplyr)
t1 <- tibble(a = rnorm(5), b = rnorm(5))
t2 <- tibble(c = runif(5), d = runif(5))
t1 - t2
#> a b
#> 1 0.43871653 -0.7512329
#> 2 -1.28601158 -1.9205421
#> 3 -0.32871328 1.5004114
#> 4 0.05049482 0.5139137
#> 5 0.45431175 -0.7676874
class(t1 - t2)
#> [1] "data.frame"
I'll look into this, but I would rather not define tidytable methods for all mathematical operators. Especially since it doesn't appear to work in dplyr
either.
I think I'm going to close this one. Since it doesn't work with tibbles, I'm ok with it not working in tidytable either.
I know probably this is an edge case. This is the first time I need to subtract to dataframes as if they were matrix, but I think it's also easy to fix just adding a method to
-
for tidytable, isn't it?Created on 2024-01-19 with reprex v2.1.0