【发布时间】:2019-10-11 05:37:44
【问题描述】:
我正在设置一个带有闪亮仪表板的网络应用程序,以显示来自谷歌分析的数据。 我想让用户选择他想通过表单(plot1,plot2,plot3)在哪个图中显示数据。 当我单击操作按钮(类似于 output$(input$select_plot))时,我想检索位置(input$select_plot)并在所选图中生成数据:
我尝试了不同的方法(使用响应式)但仍然不起作用,我不知道它是否可能
这是我的代码:
ui.R
tabItem("perso2", h1("Sub-item 2 tab content"),
hr(),
fluidRow(
column(3, wellPanel(
selectInput("select2", label = h3("Metrics"),
multiple = TRUE,
choices = list("Users" = "users",
"New users" = "newUsers",
"Sessions" = "sessions",
"Session Duration" = "sessionDuration",
"Average session" = "avgSessionDuration"),
selected = 1),
selectInput("select_plot", label = h3("Select box"),
choices = list("Choice 1" = "plot1", "Choice 2" = "plot2", "Choice 3" = "plot3")),
actionButton("do", "Click Me")
))),
fluidRow(
column(width = 4, plotOutput("plot1")),
column(width = 4, plotOutput("plot2")),
column(width = 4, plotOutput("plot3"))
)
)
和服务器.R
dataaa <- eventReactive(input$do, {
token <- auth$token()
time <- rollupGA(GAProfileTable = getprofile(),
start_date = "2019-04-04",
end_date = "2019-04-11",
metrics = paste("ga:",input$select2, collapse=NULL, sep=""),
ga = token)
time[,c('date',input$select2)]
})
selected_plot <- reactive({ input <- select_plot })
output$selected_plot <- renderPlot({
validate(
need(getprofile(), "Authentificate to see"))
plot(dataaa())
})
如果用户选择“Choice 3”,我希望在 plotOutput("plot3") 中生成一个绘图, 有解决方案或其他方法吗?
感谢
【问题讨论】:
标签: r plot google-analytics shiny