更改r markdown HTML中嵌入的闪亮应用的维度

时间:2016-04-10 15:19:41

标签: r r-markdown shiny

我在r markdown脚本中有一个嵌入式闪亮应用程序,它与HTML编织在一起。目前,当我编织包含闪亮应用程序的r markdown chunk时,应用程序未以完整大小显示。 r markdown包括一个较小的窗口内的闪亮应用程序。我需要使用窗口滑块/滚动条来查看整个应用程序。

我认为这是一个降价问题,并尝试使用fig.widthfig.height更改块尺寸,但无济于事。

我想要在完整范围内显示闪亮的应用程序,我可以在一个视图中查看整个绘图和包含的滑块。

任何建议将不胜感激。下面提供了可重现的r降价脚本,其中包含dput中包含的数据。任何建议都将不胜感激。

---
output: html_document
runtime: shiny
---

```{r Packages, include=FALSE}
library(ggplot2)
library(shiny)
```


```{r Data, include=FALSE}
dat <- structure(list(AcquisitionStartTime = structure(c(1L, 2L, 5L, 
6L, 8L, 9L, 10L, 12L, 13L, 14L, 15L), .Label = c("2013.02.09 00:00:00", 
"2013.02.09 06:00:00", "2013.02.09 12:00:00", "2013.02.09 18:00:00", 
"2013.02.10 00:00:00", "2013.02.10 06:00:00", "2013.02.10 12:00:00", 
"2013.02.10 18:00:00", "2013.02.11 00:00:00", "2013.02.11 06:00:00", 
"2013.02.11 12:00:00", "2013.02.11 18:00:00", "2013.02.12 00:00:00", 
"2013.02.12 06:00:00", "2013.02.12 12:00:00"), class = "factor"), 
    GPSUTMNorthing = c(4947787L, 4947945L, 4947957L, 4947954L, 
    4947797L, 4947835L, 4947825L, 4947784L, 4947842L, 4947839L, 
    4947789L), GPSUTMEasting = c(600201L, 600910L, 600911L, 600907L, 
    601052L, 601038L, 601031L, 601066L, 600998L, 600995L, 601058L
    )), .Names = c("AcquisitionStartTime", "GPSUTMNorthing", 
"GPSUTMEasting"), row.names = c(1L, 2L, 5L, 6L, 8L, 9L, 10L, 
12L, 13L, 14L, 15L), class = "data.frame")
```



```{r Time, include=FALSE}
dat$PosiGMT <- as.POSIXct(strptime(as.character(dat$AcquisitionStartTime),"%Y.%m.%d %H:%M:%S"))
```

### Header One: 
Headers, text, and figures here...


### Interactive shinyApp
```{r, echo = FALSE, fig.height=6}
shinyApp(
ui <- fluidPage(
          titlePanel("GPS Data Summary"),
          sliderInput(inputId = "Date",
                  label = "Sequance of Observations",  
                  min = as.Date(min(dat$PosiGMT)), max = as.Date(max(dat$PosiGMT)),
                  value = as.Date(min(dat$PosiGMT))),
                  #animate = animationOptions(interval=75, loop=T)),
          plotOutput("PointPlot")
            ),

server <- function(input, output) {
            output$PointPlot <- renderPlot({
              p <- ggplot(dat[as.Date(dat$PosiGMT) <= input$Date ,], 
                          (aes(x = GPSUTMEasting, y = GPSUTMNorthing ))) + 
                geom_point() + geom_path() + 
                xlim( min(dat$GPSUTMEasting), max(dat$GPSUTMEasting))+
                ylim( min(dat$GPSUTMNorthing), max(dat$GPSUTMNorthing))
              print(p)
              })
}

)
```


### More headers below 
More text and figures here...    

1 个答案:

答案 0 :(得分:2)

嵌入式Shiny app的高度通过添加

来控制
&amp;

在右括号之前。即。

options = list(height = 500)

在添加的这一行之前不要忘记 .... ylim(min(dat$GPSUTMNorthing), max(dat$GPSUTMNorthing)) print(p) }) }, options = list(height = 600) ) ```