我在创建一个基于四个sliderInput控件生成计算字段的动态表时遇到问题,其中一次sliderInput确定数据帧的长度。
library(shiny)
# Define server logic for random distribution application
shinyServer(function(input, output) {
sliderValues <- reactive ({
#compose data frame
ws<- as.numeric (c(0:input$sws))
df<-data.frame(
WindSpeed = as.character (c(ws)
),
CBH = as.character (c(input$sCBH)
),
FFMC = as.character(c(input$sFFMC)
),
DC = as.character (c(input$sDC)
),
PCFI = as.character (c((exp(-66.62+(-0.993*input$sCBH)+(0.568*ws)+(0.671*input$sFFMC)+(0.018*input$sDC)))/(1+(exp(-66.62+(-0.993*input$sCBH)+(0.568*input$sws)+(0.671*input$sFFMC)+(0.018*input$sDC)))))
)
)
return(df)
})
#Show the values using an HTML table
output$values <- renderTable({
sliderValues()
})
})
基本上我想使用renderTable生成一个表,该表根据其他sliderInputs将PCFI中的字段相乘。但是,目前通过使用ws&lt; - as.numeric(c(0:input $ sws)),它将整个列表乘以变量。我一整天都在努力生产出正确的产品,所以任何帮助都会很棒。
shinyUI
(fluidPage(
titlePanel("Behaviour Model"),
#Sidebar with sliders that demonstrate various available
#options
sidebarLayout(
sidebarPanel(
#Simple integer interval
sliderInput ("sws", "10m Wind Speed (km/hr):",
min=0,
max=50,
value=15),
sliderInput ("sCBH", "Crown Base Height (m):",
min=0,
max=25,
value=5),
sliderInput ("sFFMC", "Fine Fuel Moisutre Code:",
min = 77,
max=98,
value = 88,
step=1.0),
sliderInput("sDC", "Drought Code:",
min=0,
max= 1000,
value = 200)
),
#Show a table summarizing the values entered
mainPanel(
tableOutput("values")
)
)
))
理想情况下,最后我将有一个类似于以下内容的表,而没有PCFI字段计算整个ws&lt; - as.numeric(c(0:input $ sws)),只是单个增量每行风速:
WindSpeed CBH FFMC DC PCFI
0 5 88 200 *calculated field*
1 5 88 200 *calculated field*
2 5 88 200 *calculated field*
3 5 88 200 *calculated field*
4 5 88 200 *calculated field*
5 5 88 200 *calculated field*
... ...
Length Dependent on Windspeed Slider, as each record is calculated in +1km/hr increments.
再一次,我真的很感激任何帮助。 凯文
这就是输出表的样子:
CBH WindSpeed FFMC DC PCFI
4 0 92 200 0.005168453
4 1 92 200 0.009085037
4 2 92 200 0.015922053
4 3 92 200 0.027760177
4 4 92 200 0.047970947
4 5 92 200 0.081660255
4 6 92 200 0.135638245
4 7 92 200 0.216870104
4 8 92 200 0.328274418
4 9 92 200 0.46306739
4 10 92 200 0.60348325