I am working on the below table in R and would like to add the last row containing the totals for each column. I used this code:
janitor::adorn_totals("row", fill = "-",na.rm = TRUE)
but get the sum of each column. However, I only want the sum of selected columns (population, cases, and deaths) but I also want to compute the total attack rate as (total cases/total population*10000) and the total CFR as (total deaths/total Cases*100). I would be grateful for your help with this as I am a new user of R.
tab <- read.table(sep = ";", dec = ".", check.names = FALSE, stringsAsFactors = FALSE, header = TRUE,
text = "
Area; Population; Cases; Attack Rate (per 100000); Deaths; CFR (%)
A; 216767; 18; 8.3; 0; 0
B; 181160; 17; 9.4; 0; 0
C; 478978; 717; 87.1; 16; 3.8
D; 446411; 13; 2.9; 0; 0
E; 268476; 3; 1.1; 0; 0
F; 494289; 45; 9.1; 2; 4.4
G; 106303; 9; 8.5; 0; 0
H; 173990; 8; 4.6; 0; 0
")