小编the*_*eil的帖子

Shiny:有没有办法通过在tabsPanel()之间切换来触发observeEvent()

我正在开发一个闪亮的应用程序,我想知道是否有可能,或者其他人是否能够通过observeEvent()tabPanel().

tabPanel()由于@SriPaladugu代码和@DeanAttali闪亮js包,我有启用和禁用一旦执行某些操作的经验,但在回答我自己的问题时,我不知道这两种方法/包的范围。

我需要触发一个observeEvent()以便removeNotification()在选项卡之间切换时执行和删除任何警告窗口。

我想象的这样做的方式是这样的:

    observeEvent(input$tabSwitch, {
        removeNotification(previous.warning.message)
    })
Run Code Online (Sandbox Code Playgroud)

但是,没有办法使切换选项卡成为 eventExpr 从而使上面的代码可执行

如果有人已经做到了这一点或了解如何做到这一点,我将不胜感激。

notifications tabs r shiny

4
推荐指数
1
解决办法
3450
查看次数

Shiny:使用shinyjs禁用tabPanel()

我正在使用此处提供的 @SriPaladugu 的答案来禁用 a tabPanel(),并且我注意到如果 中存在空格,则它不起作用tabPanel(title,...)。他们编写了自己的 JavaScript 代码并用于shinyjs启用/禁用面板,而我不熟悉解决此问题的 JavaScript 代码。他们执行此操作的代码存储在对象中jscode;如何修改代码以解决 中的空格tabPanel(title,...)

library(shiny)
library(shinyjs)

jscode <- "
shinyjs.disableTab = function(name) {
var tab = $('.nav li a[data-value=' + name + ']');
tab.bind('click.tab', function(e) {
e.preventDefault();
return false;
});
tab.addClass('disabled');
}

shinyjs.enableTab = function(name) {
var tab = $('.nav li a[data-value=' + name + ']');
tab.unbind('click.tab');
tab.removeClass('disabled');
}
"
css <- "
.nav li a.disabled {
background-color: #aaa !important;
color: #333 !important; …
Run Code Online (Sandbox Code Playgroud)

javascript r shiny shinyjs

4
推荐指数
1
解决办法
2288
查看次数

来自 selectInput 的具有多个条件的闪亮 R 观察事件

我正在开发一个闪亮的应用程序,但observeEvent()在创建所有从selectInput().

我的问题是observeEvent()函数中的一些表达式在启动时被触发,导致事件过早执行(即我actionButton()在启动时被禁用,应该是,但在理想情况下选择至少一个输入时启用希望它仅在选择所有输入时启用)。如下图所示:

  observeEvent({
    #input$cohort_file
    input$cohort_IDvar
    input$cohort_index_date
    input$cohort_EOF_date
    input$cohort_EOF_type
    input$cohort_Y_name
    input$cohort_L0
  }, {
    enable("set_cohort_button")
  })
Run Code Online (Sandbox Code Playgroud)

作为参考,我正在使用shinyjs@daattali 在 github 上找到的包来启用/禁用actionButton()

除了最后一个输入(即input$cohort_L0)似乎在启动时已初始化,因此仅在选择时observeEvent()启用。如果您运行我的应用程序并按从上到下的顺序选择输入,则似乎按预期工作。当我决定随机选择输入并发现选择是我需要选择以启用.actionButtoninput$cohort_L0observeEvent()input$cohort_L0actionButton()

代码的 UI 部分如下所示:

# Variable selection
                          selectInput('cohort_IDvar', 'ID', choices = ''),
                          selectInput('cohort_index_date', 'Index date', choices = ''),
                          selectInput('cohort_EOF_date', 'End of follow-up date', choices = ''),
                          selectInput('cohort_EOF_type', 'End of follow-up reason', choices = ''),
                          selectInput('cohort_Y_name', 'Outcome', choices = ''),
                          selectInput('cohort_L0', 'Baseline …
Run Code Online (Sandbox Code Playgroud)

r rstudio shiny shinyjs

2
推荐指数
1
解决办法
6547
查看次数

在R中的句点和数字之间插入字符串

我有一个像这样的字符串向量:

test <- c("A1.7","A1.8")
Run Code Online (Sandbox Code Playgroud)

我想使用正则表达式A1c<=在句点和数字之间插入,如下所示:

A1.A1c<=7 A1.A1c<=8
Run Code Online (Sandbox Code Playgroud)

我浏览了问题,发现@zx8754 类似的问题;我试图修改他们问题中发布的答案,但没有运气

insert <- 'A1c<='
n <- 4
old <- test
lhs <- paste0('([[:alpha:]][[:digit:]][[:punct:]]{', n-1, '})([[:digit:]]+)$')
rhs <- paste0('\\1', insert, '\\2')
gsub(lhs, rhs, test)
Run Code Online (Sandbox Code Playgroud)

谁能指导我如何正确执行此操作?

regex r character gsub

2
推荐指数
1
解决办法
236
查看次数

标签 统计

r ×4

shiny ×3

shinyjs ×2

character ×1

gsub ×1

javascript ×1

notifications ×1

regex ×1

rstudio ×1

tabs ×1