Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/78.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闪亮应用程序:使用renderPlot expr的输入调整绘图区域的大小_R_Shiny - Fatal编程技术网

R闪亮应用程序:使用renderPlot expr的输入调整绘图区域的大小

R闪亮应用程序:使用renderPlot expr的输入调整绘图区域的大小,r,shiny,R,Shiny,是否可以根据在renderPlotexpr中创建的某个对象来更改闪亮绘图区域的高度 这里有一个简单的例子,几乎可以满足我的需要。这会根据会话特征调整窗口大小: library(shiny) runApp(list( ui = fluidPage( plotOutput("plot1", height="auto") ), server = function(input, output, session) { output$plot1 <- renderPlot(

是否可以根据在
renderPlot
expr
中创建的某个对象来更改闪亮绘图区域的高度

这里有一个简单的例子,几乎可以满足我的需要。这会根据会话特征调整窗口大小:

library(shiny)
runApp(list(
  ui = fluidPage(
    plotOutput("plot1", height="auto")
  ),
  server = function(input, output, session) {
    output$plot1 <- renderPlot({
      plot(cars)
    }, height = function() {
      session$clientData$output_plot1_width
    })
  }
))
在这种情况下,我在
renderPlot
的表达式中创建
l
,然后尝试使用
l
来调整表达式外部的绘图区域大小


谢谢你的任何线索

您可以使用
renderUI/uiOutput
动态设置绘图高度,使用
reactiveValues
renderPlot
传输值:

runApp(list(
  ui = fluidPage(uiOutput("ui1")),
  server = function(input, output, session) {
    my <- reactiveValues(l = 500)

    output$ui1 <- renderUI(plotOutput("plot1", height=my$l))

    output$plot1 <- renderPlot({
      my$l <- length(unique(cars$speed))*100
      plot(cars)
    })
  }
))
runApp(列表(
ui=流体页面(uiOutput(“ui1”)),
服务器=功能(输入、输出、会话){
我的
runApp(list(
  ui = fluidPage(uiOutput("ui1")),
  server = function(input, output, session) {
    my <- reactiveValues(l = 500)

    output$ui1 <- renderUI(plotOutput("plot1", height=my$l))

    output$plot1 <- renderPlot({
      my$l <- length(unique(cars$speed))*100
      plot(cars)
    })
  }
))