0
shinydashboardで光沢を使用します。私は2つのtabPanelsを持つ1つのタブボックスを持っています。 tabboxが選択されている場合はtextOutput( "a")、tab2が選択されている場合はtextOutput( "b")のいずれかを表示する別のボックスがあります。shinydashboardで選択されたタブボックスに基づく条件付き表示
私は再現性のためにコード全体を提供しますが、重要な部分がどこにあるかを示すコメントを注意してください。
library(shiny)
library(shinydashboard)
ui<-dashboardPage(skin = "red",
dashboardHeader(title="lalala",titleWidth = 450),
sidebar <-dashboardSidebar(width=400,
sidebarMenu(
menuItem(text = strong("First tab"),tabName="first",icon = icon("dashboard"))
)),
body <- dashboardBody(
fluidRow(
tabBox(
title = "First tabBox",
id = "tabset1", height = "250px",
############## based on which of this tab is selected
tabPanel("Tab1", "First tab content"),
tabPanel("Tab2", "Tab content 2")
),
box(
title = "Selection criteria for chart", height = "700px",width = 4, solidHeader = TRUE,status="danger",
############## I want in this box to display either textouput "a" or "b"
textOutput("a")
)
)))
server<-function(input,output){
output$a<-renderText(
a<-"ahoj"
)
output$b<-renderText(
b<-"cau"
)
}
さて、私はserver.R出力$ x <-renderText({input $ tabset1})のようなものを試してから、(textOutput( "x")== "Tab1"なら)ui.Rでテストしました。 {"a " } else { " b " }これは動作しません。または、server.Rでテストすることを意味しますか? –
'if'ロジックはサーバー側でのみ動作します。 –
出力$ x <-renderText({input $ tabset1}) if(出力$ x == "Tab1"){ 出力$ y = renderText(y < - "hahah") } else { 出力$ y = renderText(y < - "bebebe") }まだ動作しません –