From 5761ca57dd19d0cb5a30ea3d1efd98af16d235c8 Mon Sep 17 00:00:00 2001 From: Fausto Lopez Date: Fri, 29 Sep 2023 15:06:37 -0400 Subject: [PATCH 1/3] Add POC for comparing datapack value vs datim - Add POC for comparing datapack value vs datim --- server.R | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/server.R b/server.R index bf956bc..74d2790 100644 --- a/server.R +++ b/server.R @@ -966,6 +966,27 @@ shinyServer(function(input, output, session) { params <- list("colGrandTotals" = FALSE, "rowGrandTotals" = FALSE) + # difference between datapack value and datim value + if(!is.null(d$memo$datim$analytics)) { + + # TODO fix join to actual table - now this is a dummy for POC + # need second table name for the join + diff_memo_data_analytics <- + dplyr::full_join(d$memo$datim$analytics, d$data$analytics) %>% + select(ou, ou_uid, country_name, mechanism_code, target_value) + + # dummy data as second value for diff right now + diff_memo_data_analytics <- diff_memo_data_analytics %>% + mutate(target_value2 = sample(1:100, nrow(diff_memo_data_analytics), replace = T)) %>% + mutate(diff = target_value - target_value2) %>% + select(ou, ou_uid, country_name, mechanism_code, diff) + + # add diff between datapack value and datim value + wb <- wb %>% + openxlsx2::wb_add_worksheet("Datapack vs Datim") %>% + openxlsx2::wb_add_data(x = diff_memo_data_analytics) + } + wb <- wb %>% openxlsx2::wb_add_worksheet(sheet = "By SNU1") %>% openxlsx2::wb_add_pivot_table( From cf32370b273ebdc24cde5db90ac289d33357b15d Mon Sep 17 00:00:00 2001 From: Fausto Lopez Date: Thu, 5 Oct 2023 16:10:20 -0400 Subject: [PATCH 2/3] attempt merge to d$data$analytics attempt merge to d$data$analytics --- .DS_Store | Bin 0 -> 6148 bytes server.R | 38 +++++++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0% + mutate(across(where(is.character), stringr::str_trim)) %>% + dplyr::rename(datim_value = target_value) + + datapack <- d$data$analytics %>% + mutate(across(where(is.character), stringr::str_trim)) %>% + dplyr::rename(datapack_value = target_value) + + print("datpack value:") + print(unique(datapack$mechanism_code)) + #print(summary(datapack)) + #print(summary(datapack$datapack_value)) + + print("datim value:") + print(unique(datim$mechanism_code)) + #print(summary(datim)) + #print(summary(datim$datim_value)) + + #write.csv(datim[, c("dataelement_id", "categoryoptioncombo_id", "psnu_uid", "fiscal_year", "mechanism_code", "datim_value")], "datim.csv", row.names = F) + #write.csv(datapack[, c("dataelement_id", "categoryoptioncombo_id", "psnu_uid", "fiscal_year", "mechanism_code", "datapack_value")], "datapack.csv", row.names = F) - # TODO fix join to actual table - now this is a dummy for POC - # need second table name for the join diff_memo_data_analytics <- - dplyr::full_join(d$memo$datim$analytics, d$data$analytics) %>% - select(ou, ou_uid, country_name, mechanism_code, target_value) - - # dummy data as second value for diff right now - diff_memo_data_analytics <- diff_memo_data_analytics %>% - mutate(target_value2 = sample(1:100, nrow(diff_memo_data_analytics), replace = T)) %>% - mutate(diff = target_value - target_value2) %>% - select(ou, ou_uid, country_name, mechanism_code, diff) + dplyr::full_join(datim, datapack, by = c("dataelement_id", "categoryoptioncombo_id", "psnu_uid", "fiscal_year", "mechanism_code")) %>% + mutate(diff = datim_value - datapack_value) %>% + select(datim_value, datapack_value, diff) + + #write.csv(diff_memo_data_analytics, "diff_memo_data_analytics.csv", row.names = F) # add diff between datapack value and datim value wb <- wb %>% From db9e223f496b3c8a9db1da73c50f050d91741ed5 Mon Sep 17 00:00:00 2001 From: Fausto Lopez Date: Fri, 6 Oct 2023 12:13:56 -0400 Subject: [PATCH 3/3] remove hashed code -removed hashed code --- server.R | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/server.R b/server.R index 62af575..efcfc09 100644 --- a/server.R +++ b/server.R @@ -977,26 +977,11 @@ shinyServer(function(input, output, session) { mutate(across(where(is.character), stringr::str_trim)) %>% dplyr::rename(datapack_value = target_value) - print("datpack value:") - print(unique(datapack$mechanism_code)) - #print(summary(datapack)) - #print(summary(datapack$datapack_value)) - - print("datim value:") - print(unique(datim$mechanism_code)) - #print(summary(datim)) - #print(summary(datim$datim_value)) - - #write.csv(datim[, c("dataelement_id", "categoryoptioncombo_id", "psnu_uid", "fiscal_year", "mechanism_code", "datim_value")], "datim.csv", row.names = F) - #write.csv(datapack[, c("dataelement_id", "categoryoptioncombo_id", "psnu_uid", "fiscal_year", "mechanism_code", "datapack_value")], "datapack.csv", row.names = F) - diff_memo_data_analytics <- dplyr::full_join(datim, datapack, by = c("dataelement_id", "categoryoptioncombo_id", "psnu_uid", "fiscal_year", "mechanism_code")) %>% mutate(diff = datim_value - datapack_value) %>% select(datim_value, datapack_value, diff) - #write.csv(diff_memo_data_analytics, "diff_memo_data_analytics.csv", row.names = F) - # add diff between datapack value and datim value wb <- wb %>% openxlsx2::wb_add_worksheet("Datapack vs Datim") %>%