From b391fd91feb6cdbc771fb0582bcfc14c41ce4dad Mon Sep 17 00:00:00 2001 From: kartikeya kirar Date: Wed, 12 Jun 2024 19:39:07 +0000 Subject: [PATCH 1/4] fixing Loq calcualtion. --- R/tm_g_gh_correlationplot.R | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/R/tm_g_gh_correlationplot.R b/R/tm_g_gh_correlationplot.R index 09999d63..7986b95a 100644 --- a/R/tm_g_gh_correlationplot.R +++ b/R/tm_g_gh_correlationplot.R @@ -609,7 +609,8 @@ srv_g_correlationplot <- function(id, yvar <- reactive(paste0(input$yaxis_var, ".", input$yaxis_param)) xloqfl <- reactive(paste0("LOQFL_", input$xaxis_param)) yloqfl <- reactive(paste0("LOQFL_", input$yaxis_param)) - + xlabs <- reactive(paste0("LBSTRESC_", input$xaxis_param)) + ylabs <- reactive(paste0("LBSTRESC_", input$yaxis_param)) # transpose data to plot plot_data_transpose <- reactive({ teal::validate_inputs(iv_r()) @@ -676,17 +677,33 @@ srv_g_correlationplot <- function(id, sep = "_", remove = TRUE ) %>% - tidyr::pivot_wider(names_from = "ANL.PARAM", values_from = "ANLVALS") %>% - dplyr::mutate(LOQFL_COMB = dplyr::case_when( - .data[[.(xloqfl())]] == "Y" | .data[[.(yloqfl())]] == "Y" ~ "Y", - .data[[.(xloqfl())]] == "N" & .data[[.(yloqfl())]] == "N" ~ "N", - .data[[.(xloqfl())]] == "N" & .data[[.(yloqfl())]] == "NA" ~ "N", - .data[[.(xloqfl())]] == "NA" & .data[[.(yloqfl())]] == "N" ~ "N", - .data[[.(xloqfl())]] == "NA" & .data[[.(yloqfl())]] == "NA" ~ "NA", - TRUE ~ as.character(NA) - )) + tidyr::pivot_wider(names_from = "ANL.PARAM", values_from = "ANLVALS") ANL_TRANSPOSED <- merge(ANL_TRANSPOSED1, ANL_TRANSPOSED2) # nolint + ANL_TRANSPOSED <- ANL_TRANSPOSED %>% + dplyr::mutate( + x_temp = ifelse( + .data[[.(xloqfl())]] == "Y" & ( + (grepl("<", .data[[.(xlabs())]]) & .data[[.(xvar())]] < as.numeric(gsub("[^0-9.-]", "", .data[[.(xlabs())]]))) | + (grepl(">", .data[[.(xlabs())]]) & .data[[.(xvar())]] > as.numeric(gsub("[^0-9.-]", "", .data[[.(xlabs())]]))) + ), "Y", ifelse(.data[[.(xloqfl())]] == "Y", "N", as.character(.data[[.(xloqfl())]]) + )), + y_temp = ifelse( + .data[[.(yloqfl())]] == "Y" & ( + (grepl("<", .data[[.(ylabs())]]) & .data[[.(yvar())]] < as.numeric(gsub("[^0-9.-]", "", .data[[.(ylabs())]]))) | + (grepl(">", .data[[.(ylabs())]]) & .data[[.(yvar())]] > as.numeric(gsub("[^0-9.-]", "", .data[[.(ylabs())]]))) + ), "Y", ifelse(.data[[.(yloqfl())]] == "Y", "N", as.character(.data[[.(yloqfl())]]) + ) + )) %>% + dplyr::mutate(LOQFL_COMB = dplyr::case_when( + x_temp == "Y" | y_temp == "Y" ~ "Y", + x_temp == "N" & y_temp == "N" ~ "N", + x_temp == "N" & y_temp == "NA" ~ "N", + x_temp == "NA" & y_temp == "N" ~ "N", + x_temp == "NA" & y_temp == "NA" ~ "NA", + TRUE ~ as.character(NA) + ))%>% + dplyr::select(-x_temp, -y_temp) }) ) From 3022bc186963705c3035072cf3692a669513a47c Mon Sep 17 00:00:00 2001 From: kartikeya kirar Date: Wed, 12 Jun 2024 19:42:20 +0000 Subject: [PATCH 2/4] adding NEWS --- NEWS.md | 1 + R/tm_g_gh_correlationplot.R | 1 + 2 files changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 81d1dd53..1363e1f7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # teal.goshawk 0.1.15.9023 * Removed `Show Warnings` modals from modules. +* Fixed `LOQFL_COMB` calculation. ### Breaking Changes * Adapted all modules to use `teal_data` objects. diff --git a/R/tm_g_gh_correlationplot.R b/R/tm_g_gh_correlationplot.R index 7986b95a..eaf740e2 100644 --- a/R/tm_g_gh_correlationplot.R +++ b/R/tm_g_gh_correlationplot.R @@ -611,6 +611,7 @@ srv_g_correlationplot <- function(id, yloqfl <- reactive(paste0("LOQFL_", input$yaxis_param)) xlabs <- reactive(paste0("LBSTRESC_", input$xaxis_param)) ylabs <- reactive(paste0("LBSTRESC_", input$yaxis_param)) + # transpose data to plot plot_data_transpose <- reactive({ teal::validate_inputs(iv_r()) From 2495481599de4f7eadc32b7fce29daab4f2787a6 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:51:45 +0000 Subject: [PATCH 3/4] [skip style] [skip vbump] Restyle files --- R/tm_g_gh_correlationplot.R | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/R/tm_g_gh_correlationplot.R b/R/tm_g_gh_correlationplot.R index eaf740e2..7ed97764 100644 --- a/R/tm_g_gh_correlationplot.R +++ b/R/tm_g_gh_correlationplot.R @@ -687,24 +687,24 @@ srv_g_correlationplot <- function(id, .data[[.(xloqfl())]] == "Y" & ( (grepl("<", .data[[.(xlabs())]]) & .data[[.(xvar())]] < as.numeric(gsub("[^0-9.-]", "", .data[[.(xlabs())]]))) | (grepl(">", .data[[.(xlabs())]]) & .data[[.(xvar())]] > as.numeric(gsub("[^0-9.-]", "", .data[[.(xlabs())]]))) - ), "Y", ifelse(.data[[.(xloqfl())]] == "Y", "N", as.character(.data[[.(xloqfl())]]) - )), - y_temp = ifelse( - .data[[.(yloqfl())]] == "Y" & ( - (grepl("<", .data[[.(ylabs())]]) & .data[[.(yvar())]] < as.numeric(gsub("[^0-9.-]", "", .data[[.(ylabs())]]))) | - (grepl(">", .data[[.(ylabs())]]) & .data[[.(yvar())]] > as.numeric(gsub("[^0-9.-]", "", .data[[.(ylabs())]]))) - ), "Y", ifelse(.data[[.(yloqfl())]] == "Y", "N", as.character(.data[[.(yloqfl())]]) - ) - )) %>% - dplyr::mutate(LOQFL_COMB = dplyr::case_when( - x_temp == "Y" | y_temp == "Y" ~ "Y", - x_temp == "N" & y_temp == "N" ~ "N", - x_temp == "N" & y_temp == "NA" ~ "N", - x_temp == "NA" & y_temp == "N" ~ "N", - x_temp == "NA" & y_temp == "NA" ~ "NA", - TRUE ~ as.character(NA) - ))%>% - dplyr::select(-x_temp, -y_temp) + ), "Y", ifelse(.data[[.(xloqfl())]] == "Y", "N", as.character(.data[[.(xloqfl())]])) + ), + y_temp = ifelse( + .data[[.(yloqfl())]] == "Y" & ( + (grepl("<", .data[[.(ylabs())]]) & .data[[.(yvar())]] < as.numeric(gsub("[^0-9.-]", "", .data[[.(ylabs())]]))) | + (grepl(">", .data[[.(ylabs())]]) & .data[[.(yvar())]] > as.numeric(gsub("[^0-9.-]", "", .data[[.(ylabs())]]))) + ), "Y", ifelse(.data[[.(yloqfl())]] == "Y", "N", as.character(.data[[.(yloqfl())]])) + ) + ) %>% + dplyr::mutate(LOQFL_COMB = dplyr::case_when( + x_temp == "Y" | y_temp == "Y" ~ "Y", + x_temp == "N" & y_temp == "N" ~ "N", + x_temp == "N" & y_temp == "NA" ~ "N", + x_temp == "NA" & y_temp == "N" ~ "N", + x_temp == "NA" & y_temp == "NA" ~ "NA", + TRUE ~ as.character(NA) + )) %>% + dplyr::select(-x_temp, -y_temp) }) ) From e7ac08c65239b2d5952b33f649d9b6cf8b355b0e Mon Sep 17 00:00:00 2001 From: Kartikeya Kirar Date: Mon, 24 Jun 2024 10:40:06 +0530 Subject: [PATCH 4/4] @gogonzo suggestions. --- R/tm_g_gh_correlationplot.R | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/R/tm_g_gh_correlationplot.R b/R/tm_g_gh_correlationplot.R index 7ed97764..924d9546 100644 --- a/R/tm_g_gh_correlationplot.R +++ b/R/tm_g_gh_correlationplot.R @@ -683,28 +683,32 @@ srv_g_correlationplot <- function(id, ANL_TRANSPOSED <- merge(ANL_TRANSPOSED1, ANL_TRANSPOSED2) # nolint ANL_TRANSPOSED <- ANL_TRANSPOSED %>% dplyr::mutate( - x_temp = ifelse( + xloqfl_temp = dplyr::case_when( .data[[.(xloqfl())]] == "Y" & ( (grepl("<", .data[[.(xlabs())]]) & .data[[.(xvar())]] < as.numeric(gsub("[^0-9.-]", "", .data[[.(xlabs())]]))) | (grepl(">", .data[[.(xlabs())]]) & .data[[.(xvar())]] > as.numeric(gsub("[^0-9.-]", "", .data[[.(xlabs())]]))) - ), "Y", ifelse(.data[[.(xloqfl())]] == "Y", "N", as.character(.data[[.(xloqfl())]])) + ) ~ "Y", + .data[[.(xloqfl())]] == "Y" ~ "N", + TRUE ~ as.character(.data[[.(xloqfl())]]) ), - y_temp = ifelse( + yloqfl_temp = dplyr::case_when( .data[[.(yloqfl())]] == "Y" & ( (grepl("<", .data[[.(ylabs())]]) & .data[[.(yvar())]] < as.numeric(gsub("[^0-9.-]", "", .data[[.(ylabs())]]))) | (grepl(">", .data[[.(ylabs())]]) & .data[[.(yvar())]] > as.numeric(gsub("[^0-9.-]", "", .data[[.(ylabs())]]))) - ), "Y", ifelse(.data[[.(yloqfl())]] == "Y", "N", as.character(.data[[.(yloqfl())]])) + ) ~ "Y", + .data[[.(yloqfl())]] == "Y" ~ "N", + TRUE ~ as.character(.data[[.(yloqfl())]]) ) ) %>% dplyr::mutate(LOQFL_COMB = dplyr::case_when( - x_temp == "Y" | y_temp == "Y" ~ "Y", - x_temp == "N" & y_temp == "N" ~ "N", - x_temp == "N" & y_temp == "NA" ~ "N", - x_temp == "NA" & y_temp == "N" ~ "N", - x_temp == "NA" & y_temp == "NA" ~ "NA", + xloqfl_temp == "Y" | yloqfl_temp == "Y" ~ "Y", + xloqfl_temp == "N" & yloqfl_temp == "N" ~ "N", + xloqfl_temp == "N" & yloqfl_temp == "NA" ~ "N", + xloqfl_temp == "NA" & yloqfl_temp == "N" ~ "N", + xloqfl_temp == "NA" & yloqfl_temp == "NA" ~ "NA", TRUE ~ as.character(NA) )) %>% - dplyr::select(-x_temp, -y_temp) + dplyr::select(-xloqfl_temp, -yloqfl_temp) }) )