- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在努力适应R Shiny: automatically refreshing a main panel without using a refresh button一个新的最小工作示例:
ui <- fluidPage(
pageWithSidebar(
headerPanel("actionButton test"),
sidebarPanel(
numericInput("n", "N:", min = 0, max = 100, value = 50),
br(),
actionButton("goButton", "Go!"),
p("Click the button to update the value displayed in the main panel."),
actionButton("newButton", "New Button"),
actionButton("newButton2", "Another New Button")
),
mainPanel(
verbatimTextOutput("nText"),
textOutput("some_text_description"),
plotOutput("some_plot")
)
)
)
server <- function(input, output, session) {
# builds a reactive expression that only invalidates
# when the value of input$goButton becomes out of date
# (i.e., when the button is pressed)
ntext <- eventReactive(input$goButton, {
input$n
})
output$nText <- renderText({
ntext()
})
# Prep some text for output
output$some_text_description <- renderText({
if (input$newButton == 0) {return(NULL)}
else {
"Lorem ipsum dolorom."
}
})
# Prep some figure for output
# Simple Bar Plot
output$some_plot <- renderPlot({
if (input$newButton2 == 0) {return(NULL)}
else {
counts <- table(mtcars$gear)
barplot(counts, main="Car Distribution", xlab="Number of Gears")
}
})
}
shinyApp(ui = ui, server = server)
在上面的代码中,我有三个 actionButton
命令,一个生成绘图,一个生成文本输出,一个生成数字(作为逐字文本输出)。当您点击每个按钮时,新的输出会与之前生成的输出(从您按下的最后一个按钮开始)一起出现。
无需实现手动清除所有内容的刷新按钮,我如何让每个 actionButton
自动覆盖(即删除)其他的输出,而不是它们全部堆叠在一起主面板。我的理解是我需要使用 observeEvent
、NULL
和 reactiveValues
的某种组合,但到目前为止我的尝试没有成功。
最佳答案
您可以为此使用 renderUI()
。
output$all <- renderUI({
global$out
})
在全局 reactiveValue global$out
中,您可以存储要显示的 ui 元素。 (最初它应该是空的,因此 NULL
)。
global <- reactiveValues(out = NULL)
然后监听按钮中的点击并相应地更新 global$out
。
observeEvent(input$goButton, {
global$out <- verbatimTextOutput("nText")
})
observeEvent(input$newButton, {
global$out <- textOutput("some_text_description")
})
observeEvent(input$newButton2, {
global$out <- plotOutput("some_plot")
})
完整的应用程序将显示:
library(shiny)
ui <- fluidPage(
pageWithSidebar(
headerPanel("actionButton test"),
sidebarPanel(
numericInput("n", "N:", min = 0, max = 100, value = 50),
br(),
actionButton("goButton", "Go!"),
p("Click the button to update the value displayed in the main panel."),
actionButton("newButton", "New Button"),
actionButton("newButton2", "Another New Button")
),
mainPanel(
uiOutput("all")
)
)
)
server <- function(input, output, session) {
global <- reactiveValues(out = NULL)
observeEvent(input$goButton, {
global$out <- verbatimTextOutput("nText")
})
observeEvent(input$newButton, {
global$out <- textOutput("some_text_description")
})
observeEvent(input$newButton2, {
global$out <- plotOutput("some_plot")
})
output$all <- renderUI({
global$out
})
output$nText <- renderText({
input$n
})
output$some_text_description <- renderText({
"Lorem ipsum dolorom."
})
# Simple Bar Plot
output$some_plot <- renderPlot({
counts <- table(mtcars$gear)
barplot(counts, main="Car Distribution", xlab="Number of Gears")
})
}
shinyApp(ui = ui, server = server)
关于R Shiny : refreshing/overriding actionButton() output,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48055272/
在我的phone-gap index.html javascript部分中,window.refresh用于IOS,this.refresh用于android。我想对两者使用相同的index.html
我正在使用 Guzzle 获取域上设置了元刷新的网页的 HTML: Guzzle 似乎没有拦截这种重定向。这是正确的吗?我可以将 Guzzle 配置为跟随刷新吗? 我应该考虑其他哪些解决方案来解决问
我试图在另一个 DropDownList 发生变化后刷新下拉列表,但是 Refresh() 方法是未定义错误正在提升。我再次尝试读取数据源,它显示它正在加载,但数据仍然相同。请帮助解决这个问题。 代码
swift 我正在努力做到这一点,当您在 tableview 上拉动刷新时,它会使用存储在 Parse.com 上的数据更新 tableview 我已经研究过了,看来我需要使用 loadObjects
我有以下物化 View - CREATE MATERIALIZED VIEW TESTRESULT ON PREBUILT TABLE WITH REDUCED PRECISION REFRESH F
我正在使用 Cognito 用户池对系统中的用户进行身份验证。成功的身份验证会提供ID token (JWT)、访问 token (JWT) 和刷新 token 。 documentation her
我想使用 FlashMessage 显示错误(或成功)消息同时让我的页面在所需时间重新加载 我正在使用 FlashMessage我的代码看起来像 render() { return ( {
更新:我已经写了一篇博文,介绍我对这个问题的了解。我仍然不完全理解它,但希望有人会阅读这篇文章并阐明我的问题:http://andymcfee.com/2012/04/04/icon-fonts-ps
所以我有一个物化 View (我知道......): CREATE MATERIALIZED VIEW vw_my_view_here REFRESH COMPLETE START WITH SYSD
我正在尝试使用 the angular-oauth2-oidc Silent Refresh实现与在 IdentityServer4 服务器中配置的隐式流相结合。我有一个在 ng new ng-and
TL;DR - 如果 oauth2 授权发生在原生 android/ios 应用程序中,我如何在后端刷新 token ? 我正在研究 oauth2 与谷歌日历的集成。我的堆栈是将 SPA 应用程序作为
作为前言,我对java很陌生。因此,请期待愚蠢的错误。 我正在尝试在 BlueJ 中使用 java 的绘图面板做一个项目,但我不知道如何制作一个具有移动对象的程序。这是一个项目,所以提供了代码。我们必
我正在尝试使用我在许多网站上找到的不显眼但非常有用的润色来润色我的网络编程技能。 Stackoverflow.com,举个例子。当我提出问题时,页面会提交问题,我的浏览器会自行重新加载并显示我的问题。
AjaxControlToolkit.dll.refresh 文件的作用是什么? 最佳答案 *.dll.refresh 文件是一个非常简单的文件,它告诉项目外部引用所在的位置。 http://mons
如何使用watir-webdrive刷新页面? 我尝试了他们在这里说的话:http://watirwebdriver.com/sending-special-keys/,但是没有运气。 browser
我目前正在制作一个交互式图表,该图表应该计算商业项目的潜在风险因素。为此,我一直在使用百度 ECharts,并让图表在视觉上工作,但是当数据发生变化时无法让图表更新。 数据来自外部调查问卷,该问卷使用
在 plupload div 之后,我有一个带有 plupload 的上传表单和一个带有 bool 值的复选框。 如果选中该复选框,我想更改 plupload 中 url 的值。 这是我的代码
我有一个相当大的PHP代码库(10k文件),可以在Windows计算机上使用Eclipse 3.4/PDT 2来工作,而这些文件则托管在Debian文件服务器上。我通过Windows上的映射驱动器进行
使用 Angularjs v0.9 和 php 来实现我的成员(member)系统 在下面的函数中,我将调用一个api来编辑成员(member)的数据,成功后,php函数将返回 {"success":
我正在使用 setColor 和 getColor 方法更改 JPanel 的颜色。 现在我想更改它,这样您就不必在调用 getColor 的函数中单击 getColor 按钮 100 毫秒。 但是在
我是一名优秀的程序员,十分优秀!