2
「在ExtractVars無效的模型公式」 這是我的閃亮的UI圖像: 錯誤閃亮
global.R代碼:
library(shiny)
library(gsheet)
library(ggvis)
library(ggplot2)
urlA <- "https://docs.google.com/spreadsheets/d/1lVVGg2iRLtOaizrkaJHtPCyEnQiKAnJPyNj1kSSPXvY/edit?usp=sharing"
urlB <- "Another URL"
urlC <- "Another URL"
urlD <- "Another URL"
urlE <- "Another URL"
p_A <- gsheet2tbl(urlA)
p_B <- gsheet2tbl(urlB)
p_C <- gsheet2tbl(urlC)
p_D <- gsheet2tbl(urlD)
p_E <- gsheet2tbl(urlE)
paintingList <- list(p_A, p_B, p_C, p_D, p_E)
A_date <- split(p_A, format(as.Date(p_A$date), "%Y-%m"))
B_date <- split(p_B, format(as.Date(p_B$date), "%Y-%m"))
C_date <- split(p_C, format(as.Date(p_C$date), "%Y-%m"))
D_date <- split(p_D, format(as.Date(p_D$date), "%Y-%m"))
E_date <- split(p_E, format(as.Date(p_E$date), "%Y-%m"))
server.R代碼:
shinyServer(function(input, output) {
productInput <- reactive({
switch(input$painting,
"A" = p_A,
"B" = p_B,
"C" = p_C,
"D" = p_D,
"E" = p_E)
})
output$paintDate <- renderUI({
if (input$painting == "A"){
selectInput("pdate", "Select a date", names(split(p_A, format(as.Date(p_A$date), "%Y-%m"))))
} else if(input$painting == "B") {
selectInput("pdate", "Select a date", names(split(p_B, format(as.Date(p_B$date), "%Y-%m"))))
} else if(input$painting == "C"){
selectInput("pdate", "Select a date", names(split(p_C, format(as.Date(p_C$date), "%Y-%m"))))
} else if(input$painting == "D"){
selectInput("pdate", "Select a date", names(split(p_D, format(as.Date(p_D$date), "%Y-%m"))))
} else if(input$painting == "E"){
selectInput("pdate", "Select a date", names(split(p_E, format(as.Date(p_E$date), "%Y-%m"))))
} else {
return()
}
})
output$paintplot <- renderPlot({
validate(need(input$pdate, ""))
plot(as.formula(paste("date ~ ", input$pdate)), data = A_date)
})
ui.R代碼:
shinyUI(fluidPage(
includeCSS("css/main.css"),
navbarPage("Plot",
tabPanel("ggPlot",
sidebarLayout(
sidebarPanel(
#add choices
selectInput("painting", "Select a option:",
choices = c("A", "B", "C", "D", "E")),
uiOutput("paintDate")
),
mainPanel(
plotOutput("paintplot"))
)
)
))
))
錯誤消息:
警告:錯誤terms.formula:在ExtractVars
我想在一列和顯示情節選擇數據無效模型公式。
如何在劇情中顯示我的選擇?
參考例子:http://shiny.rstudio.com/gallery/unicode-characters.html
請幫助我。謝謝。
謝謝。就這樣。但如何判斷其他數據呢? 'df < - data.frame(A_date [[input $ pdate]]'是固定變量 –
嗨,邁克懷斯,我突然開悟了,感謝您的幫助。 –