Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 闪亮的滑块-检索值-列表,还是。。?_R_Shiny - Fatal编程技术网

R 闪亮的滑块-检索值-列表,还是。。?

R 闪亮的滑块-检索值-列表,还是。。?,r,shiny,R,Shiny,我有一个闪亮的应用程序,在我的server.R中使用renderUI来创建一组滑块,因为我不知道提前需要创建多少个滑块。这在网页端工作得很好,但是我在检索设置值时遇到了问题。以下是我的代码中的renderUI函数: output$sliders <- renderUI({ if (input$unequalpts == "no") return(NULL) updateTabsetPanel(session, "inTabSet", selected = "Unequal") th

我有一个闪亮的应用程序,在我的server.R中使用renderUI来创建一组滑块,因为我不知道提前需要创建多少个滑块。这在网页端工作得很好,但是我在检索设置值时遇到了问题。以下是我的代码中的renderUI函数:

output$sliders <- renderUI({
if (input$unequalpts == "no")
    return(NULL)
updateTabsetPanel(session, "inTabSet", selected = "Unequal")
theSHP <- mySHPdata()
thestrata <- unique(as.character(theSHP$shnystr))
numstrata <- nlevels(theSHP$shnystr)

lapply(1:numstrata, function(i) {
      sliderInput(inputId = paste0("strata", i), label = paste("strata ", thestrata[i]),
      min = 0, max = 100, value = c(0, 100), step = 1)
      })
})

这不是我想要的;我只是想要清单[25,41,22]。我不知道为什么我没有得到一个简单的列表,而是一个列表列表?或我不知道;我不明白前导零是什么,在每个设置滑块值之前。我如何简单地从grtspts中提取25,比如说,与0.25相比

当您声明您的
滑块put
时,您分配
值=c(01100)
。从
sliderInput

滑块的初始值。长度为1的数值向量将创建一个规则滑块;长度为2的数值向量将创建一个双端范围滑块。如果该值不在最小值和最大值之间,将发出警告

您已经创建了一个双端范围滑块,因此返回两个值。要获取第二个值,可以使用


输入[[paste0(“地层”,i)]][2]

作为旁注,您应该使用
seq_len(numstrata)
,而不是
1:numstrata
,因为如果
numstrata
为0,
1:0
将返回
10
,在这种情况下,这不太可能是您想要的。
print("getting slider values...")
mysliders<- NULL
theSHP <- mySHPdata()
numstrata <- nlevels(theSHP$shnystr)
mysliders <- lapply(1:numstrata, function(i) {
    input[[paste0("strata", i)]]
    })
grtspts <-(mysliders)
print("input sliders are")
print(grtspts)
Browse[2]> grtspts
[[1]]
[1]  0 25

[[2]]
[1]  0 41

[[3]]
[1]  0 22