diff --git a/DESCRIPTION b/DESCRIPTION index aa9831e..2889c32 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,8 @@ Authors@R: c( person("Changwoo", "Lim", email = "limcw@zarathu.com", role = c("aut")), person("Jinhwan", "Kim", email = "jinhwan@zarathu.com", role = c("aut"), comment = c(ORCID = "0009-0009-3217-2417")), person("Yoonkyoung", "Jeon", email = "rachel200357@gmail.com", role = c("aut")), - person("Jaewoong", "Heo", email = "koolerjaebee@gmail.com", role = c("aut"))) + person("Jaewoong", "Heo", email = "koolerjaebee@gmail.com", role = c("aut")), + person("Youngsun", "Park", email = "ddspys@gmail.com", role = c("aut"), comment = c(ORCID = "0009-0009-9336-2281"))) Description: 'RStudio' addins and 'Shiny' modules for descriptive statistics, regression and survival analysis. Depends: R (>= 3.4.0) License: Apache License 2.0 @@ -52,7 +53,8 @@ Imports: survIDINRI, survival, timeROC, - utils + utils, + ggrepel URL: https://jinseob2kim.github.io/jsmodule/, https://github.com/jinseob2kim/jsmodule BugReports: https://github.com/jinseob2kim/jsmodule/issues Suggests: diff --git a/NAMESPACE b/NAMESPACE index 9d85f80..5e98f20 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -70,6 +70,7 @@ export(timerocModule2) export(timerocUI) import(flextable) import(ggplot2) +import(ggrepel) import(shiny) importFrom(DT,"%>%") importFrom(DT,DTOutput) diff --git a/R/line.R b/R/line.R index 479f42e..28ad4d9 100644 --- a/R/line.R +++ b/R/line.R @@ -49,9 +49,11 @@ lineUI <- function(id, label = "lineplot") { checkboxInput(ns("linetype"), "Linetype"), checkboxInput(ns("jitter"), "Jitter"), checkboxInput(ns("rev_y"), "Reverse Y-axis"), + checkboxInput(ns("label"), "Label"), uiOutput(ns("pvalue")), uiOutput(ns("subvar")), - uiOutput(ns("subval")), + uiOutput(ns("subval")) + # uiOutput(ns("size")), # uiOutput(ns("position.dodge")) ) @@ -112,6 +114,7 @@ lineUI <- function(id, label = "lineplot") { #' @rdname lineServer #' @export #' @import shiny +#' @importFrom ggrepel geom_text_repel geom_label_repel #' @importFrom data.table data.table .SD := #' @importFrom ggpubr ggline stat_compare_means geom_pwc #' @importFrom ggplot2 ggsave scale_y_reverse @@ -361,7 +364,7 @@ lineServer <- function(id, data, data_label, data_varStruct = NULL, nfactor.limi }) lineInput <- reactive({ - req(c(input$x_line, input$y_line, input$strata, input$pvalfont, input$s_pvalue, input$positiondodge)) + req(c(input$x_line, input$y_line, input$strata, input$pvalfont, input$s_pvalue, input$positiondodge, input$label)) req(input$isStrata != "None") data <- data.table(data()) @@ -373,9 +376,9 @@ lineServer <- function(id, data, data_label, data_varStruct = NULL, nfactor.limi ) if (input$jitter) { add <- switch(input$options, - "Mean_SE" = c("jitter", "mean_se"), - "Mean_SD" = c("jitter", "mean_sd"), - "Median_IQR" = c("jitter", "median_iqr") + "Mean_SE" = c("mean_se", "jitter"), + "Mean_SD" = c("mean_sd" , "jitter"), + "Median_IQR" = c("median_iqr", "jitter") ) } @@ -411,6 +414,7 @@ lineServer <- function(id, data, data_label, data_varStruct = NULL, nfactor.limi size = line.size, point.size = line.point.size, linetype = linetype + ) if (input$rev_y) { @@ -429,6 +433,30 @@ lineServer <- function(id, data, data_label, data_varStruct = NULL, nfactor.limi ) } + if (input$label) { + + + + + if(con3 <- input$strata != "None"){ + res.plot <- res.plot + + ggplot2::stat_summary(fun.data = function(x){ + return(data.frame(y = mean(x), label = round(mean(x), 2))) }, + geom = "label", + aes(label = !!sym(input$y_line), + group = !!sym(input$strata))) + }else{ + res.plot <- res.plot + + ggplot2::stat_summary(fun.data = function(x){ + return(data.frame(y = mean(x), label = round(do.call(add[1],list(x = x))[[1]], 2))) }, + geom = "label", + aes(label = !!sym(input$y_line), + )) + } + + } + + return(res.plot) })