@Shadan

I would like to repeat again that this is not really a good practice; however, if you really need to do that, here is a code that I wrote for you:

```
# Load the janitor package
library(janitor)
# Create sample data
set.seed(1)
d <- lapply(1:2, function(x) data.frame(province = sample(6, size = 3), Y = runif(3)*100, Z = runif(3)* 100))
d
[[1]]
province Y Z
1 1 90.82078 94.46753
2 4 20.16819 66.07978
3 3 89.83897 62.91140
[[2]]
province Y Z
1 2 68.70228 49.76992
2 3 38.41037 71.76185
3 5 76.98414 99.19061
# Solution using base R
lapply(d, function(x){
last_row <- nrow(x)
total <- sapply(x[, c("Y", "Z")], sum)
pct <- total / sum(total)
x[last_row+1, ] <- c("Total", total)
x[last_row+2, ] <- c("Percentage", pct)
x
[[1]]
province Y Z
1 1 90.8207789994776 94.4675268605351
2 4 20.1681931037456 66.0797792486846
3 3 89.8389684967697 62.911404389888
4 Total 200.827940599993 223.458710499108
5 Percentage 0.473330801428126 0.526669198571874
[[2]]
province Y Z
1 2 68.7022846657783 49.7699242085218
2 3 38.4103718213737 71.7618508264422
3 5 76.9841419998556 99.1906094830483
4 Total 184.096798487008 220.722384518012
5 Percentage 0.454763030547208 0.545236969452792
})
```