嗨,我正在尝试获取多个滑块,并且我希望滑块的值位于矩阵中。我正在尝试获取要在页面中打印的值作为第一步,但我收到“参数暗示不同的行数:2、0”的错误,请您帮帮我吗?
谢谢你。编码:
UI.R 库(闪亮)
attributes <- unique(prof_test[,2])
shinyUI (pageWithSidebar (
headerPanel("Attribute Model Selection"),
sidebarPanel(
lapply(1:2, function(i){
sliderInput(paste("weight",i,sep="_"),
paste("Select attribute levels :", attributes[i]),
min = 0,
max = 1,
value = 1)
})
)
, mainPanel( h3("Analysis"),
tableOutput("values")
)
)
)
SERVER.R 库(闪亮)
shinyServer( function(input,output){
sliderValues <- reactive({
data.frame(
Name = c(as.character(attributes[1]),as.character(attributes[2])),
MaxValue = c(input$weight1,
input$weight2),
stringsAsFactors=FALSE
)})
output$values <- renderTable ({
sliderValues()
})
})