I want to translate the following R code using tidytable into collapse: Advanced and Fast Data Transformation.
tidytable Code
library(tidytable)
library(collapse)
Out1 <-
wlddev %>%
mutate_rowwise.(New1 = sum(c_across.(PCGDP:GINI), na.rm = TRUE))
Out1 %>%
select.(New1)
# A tidytable: 13,176 x 1
New1
<dbl>
1 32.4
2 33.0
3 33.5
4 34.0
5 34.5
6 34.9
7 35.4
8 35.9
9 36.4
10 36.9
# ... with 13,166 more rows
collapse Code
library(collapse)
Out2 <-
wlddev %>%
ftransform(New1 = fsum(across(PCGDP:GINI), na.rm = TRUE))
Error in `context_peek()`:
! `across()` must only be used inside dplyr verbs.
Run `rlang::last_error()` to see where the error occurred.
Any hint please.
I wonder why you need to come up with something so complex. You have functions like
rowSumsin base R, and you have parallel statistical functions inkit:Created on 2022-02-05 by the reprex package (v2.0.1)