Given a dataset as follows:
df <- structure(list(type = structure(c(2L, 3L, 1L), .Label = c("negative",
"positive", "zero"), class = "factor"), count = c(10L, 5L, 8L
), percent = c(43.5, 21.7, 34.8)), class = "data.frame", row.names = c(NA,
-3L))
Out:
I woudl like to fill the value from table to the template phrase as follows:
In 2020, we have 10 cities have positive growth, which covers 43.5 % of all cities; 5 cities have zero growth, which covers 21.7 % of all cities; and 8 cities have negative growth, which covers 21.7 % of all cities.
Template:
In 2020, we have {} cities have {} growth, which covers {} % of all cities; {} cities have {} growth, which covers {} % of all cities; and {} cities have {} growth, which covers {} % of all cities.
How could I do that in R?
