2017-09-16 49 views
0

我用8只股票和12只股票進行了R降價。正如你所看到的股票圖表越來越小。有沒有辦法強制flexdashboard保持更大的寬度?當屏幕上有12個或更多的股票時,我不介意垂直滾動。R:flexdashboard縮小內容,以任何方式來防止這種情況?

rmarkdown::render('foo.Rmd') 
# creates foo.html 

enter image description here

foo.Rmd

--- 
title: "Semiconductor: 5 years" 
output: 
    flexdashboard::flex_dashboard: 
    orientation: rows 
--- 

```{r setup, include=FALSE} 
library(quantmod) 
options("getSymbols.warning4.0"=FALSE) 
options("getSymbols.yahoo.warning"=FALSE) 
getSymbols(c("APH","IBM","CCL","TSS","HSY","COH","QRVO","CMA","RJF","ABBV","SCHW","RTN"), src="yahoo", from="2012-01-01") 
``` 

Row 
------------------------------------- 
### APH 
```{r, fig.height=5} 
chartSeries(APH, type="line", subset="last 5 years", TA=NULL) 
``` 

### IBM 
```{r, fig.height=5} 
chartSeries(IBM, type="line", subset="last 5 years", TA=NULL) 
``` 

### CCL 
```{r, fig.height=5} 
chartSeries(CCL, type="line", subset="last 5 years", TA=NULL) 
``` 

### TSS 
```{r, fig.height=5} 
chartSeries(TSS, type="line", subset="last 5 years", TA=NULL) 
``` 



Row 
------------------------------------- 
### HSY 
```{r, fig.height=5} 
chartSeries(HSY, type="line", subset="last 5 years", TA=NULL) 
``` 

### COH 
```{r, fig.height=5} 
chartSeries(COH, type="line", subset="last 5 years", TA=NULL) 
``` 

### QRVO 
```{r, fig.height=5} 
chartSeries(QRVO, type="line", subset="last 5 years", TA=NULL) 
``` 

### CMA 
```{r, fig.height=5} 
chartSeries(CMA, type="line", subset="last 5 years", TA=NULL) 
``` 



Row 
------------------------------------- 
### RJF 
```{r, fig.height=5} 
chartSeries(RJF, type="line", subset="last 5 years", TA=NULL) 
``` 

### ABBV 
```{r, fig.height=5} 
chartSeries(ABBV, type="line", subset="last 5 years", TA=NULL) 
``` 

### SCHW 
```{r, fig.height=5} 
chartSeries(SCHW, type="line", subset="last 5 years", TA=NULL) 
``` 

### RTN 
```{r, fig.height=5} 
chartSeries(RTN, type="line", subset="last 5 years", TA=NULL) 
``` 

foo.Rmd(垂直滾動)

--- 
title: "Semiconductor: 5 years" 
output: 
    flexdashboard::flex_dashboard: 
    vertical_layout: scroll 
    orientation: rows 
--- 

```{r setup, include=FALSE} 
library(quantmod) 
options("getSymbols.warning4.0"=FALSE) 
options("getSymbols.yahoo.warning"=FALSE) 
getSymbols(c("MTB","IVZ","UAL","MOS","MCK","ADSK","LEG","STT","RMD","EBAY","RF","FIS"), src="yahoo", from="2012-01-01") 
``` 

Row 
------------------------------------- 
### MTB 
```{r} 
chartSeries(MTB, type="line", subset="last 5 years", TA=NULL) 
``` 

### IVZ 
```{r} 
chartSeries(IVZ, type="line", subset="last 5 years", TA=NULL) 
``` 

### UAL 
```{r} 
chartSeries(UAL, type="line", subset="last 5 years", TA=NULL) 
``` 

### MOS 
```{r} 
chartSeries(MOS, type="line", subset="last 5 years", TA=NULL) 
``` 



Row 
------------------------------------- 
### MCK 
```{r} 
chartSeries(MCK, type="line", subset="last 5 years", TA=NULL) 
``` 

### ADSK 
```{r} 
chartSeries(ADSK, type="line", subset="last 5 years", TA=NULL) 
``` 

### LEG 
```{r} 
chartSeries(LEG, type="line", subset="last 5 years", TA=NULL) 
``` 

### STT 
```{r} 
chartSeries(STT, type="line", subset="last 5 years", TA=NULL) 
``` 



Row 
------------------------------------- 
### RMD 
```{r} 
chartSeries(RMD, type="line", subset="last 5 years", TA=NULL) 
``` 

### EBAY 
```{r} 
chartSeries(EBAY, type="line", subset="last 5 years", TA=NULL) 
``` 

### RF 
```{r} 
chartSeries(RF, type="line", subset="last 5 years", TA=NULL) 
``` 

### FIS 
```{r} 
chartSeries(FIS, type="line", subset="last 5 years", TA=NULL) 
``` 
+0

Flex的設計努力,以適應您的內容,也許你需要重新考慮你的佈局,每行具有更少的地塊。 –

+0

原則上,按照[此處](http://rmarkdown.rstudio.com/flexdashboard/using.html)中所述的方法將'vertical_layout:scroll'添加到您的YAML中。 –

回答

0

添加vertical_layout: scroll您YAML

--- 
title: "Semiconductor: 5 years" 
output: 
    flexdashboard::flex_dashboard: 
    orientation: rows 
    vertical_layout: scroll 
--- 

獲取情節,以填補每個盒子的方式,以滿足使用此方法您的口味要求的實驗,根據包site

讓自己呈現大小緊密適合自己的柔性容器儘可能我們指定了每個圖表的明確fig.heightfig.width。請注意,這些尺寸的理想值通常需要通過實驗確定。

爲了提高圖的觀看,則可能更喜歡切換到突舌

--- 
title: "Semiconductor: 5 years" 
output: 
    flexdashboard::flex_dashboard: 
    vertical_layout: fill 
--- 

```{r setup, include=FALSE} 
library(quantmod) 
options("getSymbols.warning4.0"=FALSE) 
options("getSymbols.yahoo.warning"=FALSE) 
getSymbols(c("APH","IBM","CCL","TSS","HSY","COH","QRVO","CMA","RJF","ABBV","SCHW","RTN"), src="yahoo", from="2012-01-01") 
``` 

Column {.tabset} 
------------------------------------- 
### APH 
```{r} 
chartSeries(APH, type="line", subset="last 5 years", TA=NULL) 
``` 

### IBM 
```{r} 
chartSeries(IBM, type="line", subset="last 5 years", TA=NULL) 
``` 

### CCL 
```{r} 
chartSeries(CCL, type="line", subset="last 5 years", TA=NULL) 
``` 
+0

現在行周圍存在太多空白,需要將空間最小化。 – AG1

+0

@ AG1,然後移除你在每個塊上設置的'fig.height' –

+0

感謝提示,請注意我不想使用製表符。我想能夠滾動。我在最初的問題中添加了foo.Rmd的另一個變體,並且仍然有太多空白。 – AG1

1

行{數據高度的組合= 200){R,fig.height = 3,fig.width = 5} and vertical_layout:scroll已經解決了我的問題。

semi.Rmd ... R -e "rmarkdown::render('semi.Rmd')"

--- 
title: "Semiconductor: 5 years" 
output: 
    flexdashboard::flex_dashboard: 
    orientation: rows 
    vertical_layout: scroll 
--- 

```{r setup, include=FALSE} 
library(quantmod) 
# 4 stocks 
options("getSymbols.warning4.0"=FALSE) 
options("getSymbols.yahoo.warning"=FALSE) 
getSymbols(c("INTC","TXN", "QCOM","NVDA","AVGO","STM","AMD","CY","TSM","ADI"), src="yahoo", from="2012-01-01") 
``` 

Row {data-height=200} 
------------------------------------- 
### Intel 
```{r, fig.height=3, fig.width=5} 
chartSeries(INTC, type="line", subset="last 5 years", TA=NULL) 
``` 

### Qualcomm 
```{r, fig.height=3, fig.width=5} 
chartSeries(QCOM, type="line", subset="last 5 years", TA=NULL) 
``` 

### Texas Instruments 
```{r, fig.height=3, fig.width=5} 
chartSeries(TXN, type="line", subset="last 5 years", TA=NULL) 
``` 

### Broadcom 
```{r, fig.height=3, fig.width=5} 
chartSeries(AVGO, type="line", subset="last 5 years", TA=NULL) 
``` 

Row {data-height=200} 
------------------------------------- 
### ST Microelectronics 
```{r, fig.height=3, fig.width=5} 
chartSeries(STM, type="line", subset="last 5 years", TA=NULL) 
``` 

### AMD 
```{r, fig.height=3, fig.width=5} 
chartSeries(AMD, type="line", subset="last 5 years", TA=NULL) 
``` 

### Cypress 
```{r, fig.height=3, fig.width=5} 
chartSeries(CY, type="line", subset="last 5 years", TA=NULL) 
``` 

### NVDA 
```{r, fig.height=3, fig.width=5} 
chartSeries(NVDA, type="line", subset="last 5 years", TA=NULL) 
``` 

Row {data-height=200} 
------------------------------------- 
### TSMC 
```{r, fig.height=3, fig.width=5} 
chartSeries(TSM, type="line", subset="last 5 years", TA=NULL) 
``` 

### Analog Devices 
```{r, fig.height=3, fig.width=5} 
chartSeries(ADI, type="line", subset="last 5 years", TA=NULL) 
``` 
+0

你的答案是特定於你的內容,不能被推廣爲對其他人有類似問題的解決方案。 –

相關問題