我想使用tidytableR
将以下代码转换为折叠:高级和快速数据转换。
整洁的代码
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
折叠代码
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.
请有任何提示。