Hi All,
I would like to make an additional row with totals of three columns and one column with totals for summing values in rows:
aaa <- tibble::tribble(
~GDP, ~Percent,
698358, 0.5,
7521903, 4.5,
1456387, -3.2,
1152673, -1.1,
10829321, 0.7
)
Created on 2019-12-10 by the reprex package (v0.3.0)
aaa <- tibble::tribble(
~GDP, ~Percent,
698358, 0.5,
7521903, 4.5,
1456387, -3.2,
1152673, -1.1,
10829321, 0.7
)
aaa
#> # A tibble: 5 x 2
#> GDP Percent
#> <dbl> <dbl>
#> 1 698358 0.5
#> 2 7521903 4.5
#> 3 1456387 -3.2
#> 4 1152673 -1.1
#> 5 10829321 0.7
Created on 2019-12-10 by the reprex package (v0.3.0)
in order to finally look something like this:
To create a column "Total_1:", I think I would use mutate() and rowSums() ?
But more tricky would be to add an emty column with "Total_2:" in a last cell down there.
I tried to use janitor package:
aaa %>% adorn_totals()
Created on 2019-12-10 by the reprex package (v0.3.0)
but received an error:
Error: No common type for value
<character> and x
<double>.
Any help would be much appreciated.
Andrzej