Created
October 30, 2023 07:43
-
-
Save JanMarvin/0d4e567bd8a1c6f612abe765b02e966b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(openxlsx2) | |
if(exists("df_tmp")) {rm(df_tmp)} | |
a <- c("Above & Beyond", "Fully Met", "Partially Met", "Did Not Meet") # try using "&" instead of "and" | |
b <- c(.15, .70, .10, .05); | |
c <- c("","","","") | |
d <- c("","","","") | |
e <- c("","","","") | |
f <- c("","","","") | |
df_tmp <- data.frame(a,b,c,d,e,f) | |
## Add Formula(s): Summary Table ---- | |
wb <- wb_workbook()$add_worksheet("Population")$add_worksheet("Summary") | |
df_tmp$c = paste0('F',seq(4,7),'/SUM($F$4:$F$7)') | |
df_tmp$d = paste0('ROUNDDOWN((COUNTA(Population!A:A)-1)*C',seq(4,7),',0)') | |
df_tmp[1,5] = paste0('COUNTIF(Population!G:G,"Above & Beyond")') # try using "&" instead of "and" | |
df_tmp[2,5] = paste0('COUNTIF(Population!G:G,"Fully Met")') | |
df_tmp[3,5] = paste0('COUNTIF(Population!G:G,"Partially Met")') | |
df_tmp[4,5] = paste0('COUNTIF(Population!G:G,"Did Not Meet")') | |
df_tmp$f = paste0('E',seq(4,7),'-F',seq(4,7)) | |
class(df_tmp$c) <- c(class(df_tmp$c), "formula") | |
class(df_tmp$d) <- c(class(df_tmp$d), "formula") | |
class(df_tmp$e) <- c(class(df_tmp$e), "formula") | |
class(df_tmp$f) <- c(class(df_tmp$f), "formula") | |
colnames(df_tmp) <- c("Rating","Target Percentage","Actual Percentage", "Target Count", "Actual Count", "Δ to Meet Distribution Targets") | |
wb <- wb %>% wb_add_data(sheet = "Summary", df_tmp, dims = wb_dims(3, 2)) | |
if (interactive()) wb$open() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment