是否可以在同一个ui.R(闪亮)中同时使用绝对面板和sliderInput?
这是我的是否可以在同一个ui.R(闪亮)中同时使用绝对面板和sliderInput?,r,slider,shiny,R,Slider,Shiny,这是我的ui.R。这是本教程中提供的一个示例。我刚刚编辑了它 library(shiny) library(markdown) # Define UI for application that draws a histogram shinyUI(fluidPage( # Application title titlePanel("Hello Shiny!"), # Sidebar with a slider input for the number of bins sideb
ui.R
。这是本教程中提供的一个示例。我刚刚编辑了它
library(shiny)
library(markdown)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
# Application title
titlePanel("Hello Shiny!"),
# Sidebar with a slider input for the number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot"),
absolutePanel(
bottom = 0, left=420, width = 800,
draggable = TRUE,
wellPanel(
em("This panel can be moved")
)
)
))
))
还有我的服务器。R
library(shiny)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
# Expression that generates a histogram. The expression is
# wrapped in a call to renderPlot to indicate that:
#
# 1) It is "reactive" and therefore should be automatically
# re-executed when inputs change
# 2) Its output type is a plot
output$distPlot <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)
# draw the histogram with the specified number of bins
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
})**
库(闪亮)
#定义绘制直方图所需的服务器逻辑
shinyServer(功能(输入、输出){
#生成直方图的表达式。该表达式为
#包装在对renderPlot的调用中,以指示:
#
#1)它是“反应性”的,因此应自动
#输入更改时重新执行
#2)其输出类型为绘图
output$distPlotabsolutePanel使用jqueryui javascript库。它有自己的滑块。这会导致与使用jslider库的sliderInput冲突。您可以看到如下情况:
library(shiny)
runApp(
list(ui = fluidPage(
titlePanel("Hello Shiny!"),
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30)
),
mainPanel(
plotOutput("distPlot")
, tags$head(tags$script(src = "shared/jqueryui/1.10.3/jquery-ui.min.js"))
)
)
),
server = function(input, output) {
output$distPlot <- renderPlot({
x <- faithful[, 2] # Old Faithful Geyser data
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
}
)
)
库(闪亮)
runApp(
列表(ui=fluidPage)(
titlePanel(“你好,闪亮!”),
侧边栏布局(
侧栏面板(
sliderInput(“垃圾箱”,
“垃圾箱数量:”,
最小值=1,
最大值=50,
值=30)
),
主面板(
plotOutput(“distPlot”)
,tags$head(tags$script(src=“shared/jqueryui/1.10.3/jqueryui.min.js”))
)
)
),
服务器=功能(输入、输出){
输出$distPlot您在absolutePanel的参数中有一个输入错误:draggainputable=TRUE,@Fadeaway,非常抱歉,我在这里复制和粘贴时出错。现在我编辑了它。我遇到了同样的问题:在absolutePanel
调用中设置draggable=FALSE
似乎可以解决滑块的问题,但显然应该解决能够共存。如果你把滑块移到你的代码>绝对面板,它也会起作用,所以我相信当前的问题很可能是一个需要修正的bug。你可以考虑改变你的问题的标题来反映它,或者把它作为GITHUB站点上的一个bug报告。