R 使用数据框列中的SelectInput
我试图从一列中读取数据帧行,以在UI.R中的SelectInput对象中感受列表 我在用户界面和服务器之间的全局或本地引用方面有问题,我不知道在selectInput列表中导入项目的格式是否正确 这里是我的DF Ref_comp,只有一列(步骤名称): 这是我的UI.RR 使用数据框列中的SelectInput,r,shiny,R,Shiny,我试图从一列中读取数据帧行,以在UI.R中的SelectInput对象中感受列表 我在用户界面和服务器之间的全局或本地引用方面有问题,我不知道在selectInput列表中导入项目的格式是否正确 这里是我的DF Ref_comp,只有一列(步骤名称): 这是我的UI.R shinyUI(pageWithSidebar( headerPanel("My header Text"), sidebarPanel( radioButtons("test", "Select a D
shinyUI(pageWithSidebar(
headerPanel("My header Text"),
sidebarPanel(
radioButtons("test", "Select a DataBase",
c("test1"="test1",
"test2"="test2")),
textInput("card", "Enter the code card", "CARD.EX"),
textInput("comp", "Enter the ref comp", "R3"),
######## Here what I tried to do ########
selectInput("comp_sel","Component", choices=
as.character(unique(unlist(Ref_comp$STEP_NAME)))),
##########################################
downloadButton("plot_export", "Save PDF")
),
mainPanel(
#h4("Text2"),
library(plotly),
plotlyOutput("plot"))
))
这是我的服务器.R
shinyServer(function(input,output){
output$plot <- renderPlotly({
con <- odbcConnect(con, uid="xxx")
##### Here the SQL Query to have my items ######################
sql_ref = paste("select DISTINCT ...") # My SQL query on distant server
###### Output in DF Ref_comp ##############
Ref_comp <- sqlQuery(db, paste (sql_ref))
##########################################
odbcClose(data_testeur)
#### An other SQL Query for the graph #######
graph <- ggplot(...
ggplotly(graph) # Print graph
}
)
})
shinyServer(功能(输入、输出){
output$plot您的问题是,数据\u frame Ref\u comp是在server.r中生成的。在这种情况下,我们必须使用renderUI
和uiOutput()生成selectInput dynamic,如下所示:
shinyUI(pageWithSidebar(
headerPanel("My header Text"),
sidebarPanel(
radioButtons("test", "Select a DataBase",
c("test1"="test1",
"test2"="test2")),
textInput("card", "Enter the code card", "CARD.EX"),
textInput("comp", "Enter the ref comp", "R3"),
######## Here what I tried to do ########
uiOutput("selectComp"),
##########################################
downloadButton("plot_export", "Save PDF")
),
mainPanel(
#h4("Text2"),
library(plotly),
plotlyOutput("plot"))
))
和服务器
shinyServer(function(input,output){
refDataFrame <- reactive({
con <- odbcConnect(con, uid="xxx")
##### Here the SQL Query to have my items ######################
sql_ref = paste("select DISTINCT ...") # My SQL query on distant server
###### Output in DF Ref_comp ##############
Ref_comp <- sqlQuery(db, sql_ref)
odbcClose(data_testeur)
Ref_comp
})
output$selectComp <- renderUI(
selectInput("comp_sel","Component", choices=
as.character(unique(unlist(refDataFrame()[["STEP_NAME"]]))))
)
output$plot <- renderPlotly({
Ref_comp <- refDataFrame()
#### An other SQL Query for the graph #######
graph <- ggplot(...)
ggplotly(graph) # Print graph
}
)
})
shinyServer(功能(输入、输出){
refDataFrame您的问题是,数据帧Ref\u comp是在服务器中生成的。r在这种情况下,我们必须使用renderUI
和uiOutput()生成selectInput动态,如下所示:
shinyUI(pageWithSidebar(
headerPanel("My header Text"),
sidebarPanel(
radioButtons("test", "Select a DataBase",
c("test1"="test1",
"test2"="test2")),
textInput("card", "Enter the code card", "CARD.EX"),
textInput("comp", "Enter the ref comp", "R3"),
######## Here what I tried to do ########
uiOutput("selectComp"),
##########################################
downloadButton("plot_export", "Save PDF")
),
mainPanel(
#h4("Text2"),
library(plotly),
plotlyOutput("plot"))
))
和服务器
shinyServer(function(input,output){
refDataFrame <- reactive({
con <- odbcConnect(con, uid="xxx")
##### Here the SQL Query to have my items ######################
sql_ref = paste("select DISTINCT ...") # My SQL query on distant server
###### Output in DF Ref_comp ##############
Ref_comp <- sqlQuery(db, sql_ref)
odbcClose(data_testeur)
Ref_comp
})
output$selectComp <- renderUI(
selectInput("comp_sel","Component", choices=
as.character(unique(unlist(refDataFrame()[["STEP_NAME"]]))))
)
output$plot <- renderPlotly({
Ref_comp <- refDataFrame()
#### An other SQL Query for the graph #######
graph <- ggplot(...)
ggplotly(graph) # Print graph
}
)
})
shinyServer(功能(输入、输出){
refDataFrame闪亮的UI是否会在服务器代码中找到查询所在的dataframe对象?我的意思是关于UI和服务器之间的作用域对象闪亮的UI是否会在服务器代码中找到查询所在的dataframe对象?我的意思是关于UI和服务器之间的作用域对象