這是R Studio中mtcars數據集的線性迴歸。我正在嘗試創建應用程序。沒有運氣。工作幾天。對我來說編程不熟悉並沒有幫助。謝謝您的幫助。閃亮的ui.r和server.r - 我找不到讓應用程序工作的代碼
這是正確的嗎?
#server.r
data(mtcars)
mtdata<-mtcars
fit<-lm(mpg~cyl+hp+wt+qsec+am+gear,data=mtcars)
shinyServer(function(input, output) {
formulaText <- reactive({
#Not sure what this does.
paste("mpg ~", input$variable)
})
output$caption <- renderText({ # Not sure what this does.
formulaText()
})
# I am lost here. I think this part needs to 'mate up' with ui.r
output$mpgPlot <- renderPlot({
boxplot(as.formula(formulaText()), # I don't understand.
data = mtdata,
outline = input$outliers) # I don't understand.
})
})# I don't understand.
# ui.R
#fit<-lm(mpg~cyl+hp+wt+qsec+am+gear,data=mtcars)
shinyUI(fluidPage(
titlePanel("Guess which variables affect MPG!"),
# I understand sliders, radio buttons. There is a disconnect between ur
# and server.
fluidRow(
# I understand this.
column(3,
radioButtons("radio", label = h3("Cylinders"), # I understand.
choices = list("4 Cyl" = 4, "6 Cyl" =6, # I understand.
"8 Cyl" = 8),selected = 1)),
radioButtons("radio", label = h3("Number of Gears"),
choices = list("3" = 3, "4" =4,
"5" = 5),selected = 1),
#I understand this.
column(3,
selectInput("select", label = h3("Transmission Type"),
choices = list("Manual " = 1, "Automatic" =
2), selected = 1)),
fluidRow(
column(3,
sliderInput("slider1", label = h3("Horse Power"),
min = 52, max = 230, step = 5,value = 52),
sliderInput("slider2", label = h3("Weight, in tons"),
min = 1.513, max = 5.42,step = .1, value =
"min"),
sliderInput("slider3", label = h3("Quarter Mile, in
Seconds"),
min = 14.60, max = 22.90, step = .1, value
# I don't understand.
="min")), # I don't understand.
mainPanel( # I don't understand.
h3(textOutput("caption")), # I don't understand this.
plotOutput("mpgPlot") # I don't understand this.
) # I don't understand.
) # I don't understand.
) # I don't understand.
))
您是否也可以分享您的ui.R代碼? –
嗨拉斐爾。上面都是ui.r和server.r。如果你幫我,我會付給你的。我是認真的。 – xanstorm
你有沒有經過[閃亮 - 入門](http://shiny.rstudio.com/tutorial/)課程? – SymbolixAU