Revision | 7b4c16c8fccd31e5de031696a9ff23ee7c2d8450 (tree) |
---|---|
Zeit | 2022-06-30 08:56:43 |
Autor | Lorenzo Isella <lorenzo.isella@gmai...> |
Commiter | Lorenzo Isella |
I rewrote the add_total function.
@@ -4631,13 +4631,21 @@ | ||
4631 | 4631 | ## I slightly modify a function from janitor to do add the totals. |
4632 | 4632 | |
4633 | 4633 | |
4634 | +## add_total <- function(x, pos=1, ...){ | |
4635 | +## adorn_totals(x, ...) %>% | |
4636 | +## as_tibble() %>% | |
4637 | +## move_row(nrow(.)+1, pos) | |
4638 | +## } | |
4639 | + | |
4640 | +## I rewrite the function above using the native pipe. | |
4641 | + | |
4634 | 4642 | add_total <- function(x, pos=1, ...){ |
4635 | - nn <- nrow(x)+1 | |
4636 | - | |
4637 | - adorn_totals(x, ...) |> ## %>% | |
4638 | - as_tibble() |> ## %>% | |
4639 | - move_row(nn, pos) | |
4640 | -} | |
4643 | + adorn_totals(x, ...) |> | |
4644 | + as_tibble() |> | |
4645 | + (\(x) move_row(x, nrow(x)+1, pos))() | |
4646 | + | |
4647 | +} | |
4648 | + | |
4641 | 4649 | |
4642 | 4650 | |
4643 | 4651 | ## See split(d, ceiling(seq_along(d)/20)) |