当我更改菜单项时,在R闪亮中更改主体

时间:2018-08-19 04:05:04

标签: r shiny

当我选择其他球员名称时,我正在尝试改变身体。

在这里我定义了列表和矩阵

nametext <- list(c(“roger” , “rafa” , “marat”))
bodytext <- list(c(“roger text”, “rafa text”, “marat text”))
titletext <- list(c(“The GOAT” , “The Toro”, “My Idol”))
alldata <- data.frame( nametext , bodytext, titletext)

下一步,我将设置仪表板页面,包括侧边栏菜单

ui <- dashboardPage(
dashboardHeader(title = “Best Players in Tennis History”,
titleWidth = 300 #because the title is too long i had to increase the width of the header
),
dashboardSidebar(
width = 300, #to match the width of the header with the sidebar
sidebarMenu(id = “player”,
menuItem(“Roger Federer”, tabName = 1, icon = icon(“user”)),
menuItem(“Rafael Nadal”, tabName = 2, icon = icon(“flash”)),
menuItem(“Marat Safin”, tabName = 3, icon = icon(“fire”))
)
),

我将选项卡的名称定义为数字1-3。这样做的目的是从alldata矩阵中动态获取身体的数据。

所以我将这段代码添加到仪表板主体:

dashboardBody(
#Roger Federer Tab
box( print( alldata[ input&player , 2]),
title = print( alldata[ input&player ,3]),
solidHeader = TRUE,
width = 12,
height = 300
)

而且我不断收到错误消息……

ERROR: object 'input' not found

这是所有代码

nametext <- list(c(“roger” , “rafa” , “marat”))
bodytext <- list(c(“roger text”, “rafa text”, “marat text”))
titletext <- list(c(“The GOAT” , “The Toro”, “My Idol”))
alldata <- data.frame( nametext , bodytext, titletext)

ui <- dashboardPage(
dashboardHeader(title = “Best Players in Tennis History”,
titleWidth = 300 #because the title is too long i had to increase the width of the header
),
dashboardSidebar(
width = 300, #to match the width of the header with the sidebar
sidebarMenu(id = “player”,
menuItem(“Roger Federer”, tabName = 1, icon = icon(“user”)),
menuItem(“Rafael Nadal”, tabName = 2, icon = icon(“flash”)),
menuItem(“Marat Safin”, tabName = 3, icon = icon(“fire”))
)
),
dashboardBody(
#Roger Federer Tab
box( print(alldata[ input&player , 2]),
title = print(alldata[ input&player ,3]),
solidHeader = TRUE,
width = 12,
height = 300
)
)
)

server <- function(input, output) {
}

shinyApp(ui, server)

0 个答案:

没有答案