Ich habe ein einfaches lineares Modell gespeichert als .rda
Datei, die ich importieren und auf eine Reihe von Eingaben für ein glänzendes Flexdashboard anwenden möchte.Wenden Sie ein lm() -Modell in einer glänzenden App an.
Mein Code ist unten:
---
title: "Where Should I Publish My Piece?"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(shiny)
load('mods/mod.rda') # The lm() being imported
load('sections_list.rda') # A list of sections
```
Sidebar {.sidebar}
-----------------------------------------------------------------------
### Article Info
```{r}
renderText("Tell us a few things about your thing")
textInput(inputId = 'a',
label = 'What's a number?',
value = 1000)
selectInput(inputId = 'b',
label = 'What section are you using?',
choices = secs,
selected = secs[1])
selectInput(inputId = 'c',
label = 'What hour is it?',
choices = seq(0,23,1),
selected = 0)
selectInput(inputId = 'd',
label = 'What day of the week is it?',
choices = c("Thursday","Friday", "Saturday", "Sunday",
"Monday", "Wednesday", "Tuesday"),
selected = "Monday")
```
Columns {data-width=650}
-----------------------------------------------------------------------
### Predictions
```{r}
newdat <- reactive({
predict(mod,
newdata = data.frame(word_count = input$a,
section = input$b,
pub_hour = input$c,
dow = input$d))
})
renderTable({newdat})
```
ich die folgende Fehlermeldung erhalten: cannot coerce class "c("reactiveExpr", "reactive")" to a data.frame
Was kann ich dieses Problem beheben zu tun? Wenn ich später newdat
plotten möchte (mit etwas wie renderPlot({ggplot(newdat, yadayada)+geoms})
) wird das auch möglich sein?
sein sollte 'renderTable ({NEWDAT()})' Ich denke, – Chris
Das hat mich zu einem neuen Fehlermeldung anzeigt, die Spaß macht. Jetzt bekomme ich 'Faktor pub_hour hat neues Level 0'. – Josh
Niemals. Das war ein unabhängiges Problem. Vielen Dank, Chris! – Josh