2016-10-18 17 views
0

我想在我的rMarkdownioslides_presentation文件使用的formattable一个例子(link)。一切工作正常,但幻灯片中的表看起来不像我运行它只是从R而不编织HTML。formattable在我rMarkdown ioslides_presentation不起作用

```{r echo=FALSE, results='asis',error=F, warning=F} 
library(formattable) 
library(plotly) 

DF <- data.frame(Ticker=c("", "", "", "IBM", "AAPL", "MSFT"), 
       Name=c("Dow Jones", "S&P 500", "Technology", 
         "IBM", "Apple", "Microsoft"), 
       Value=accounting(c(15988.08, 1880.33, NA, 
            130.00, 97.05, 50.99)), 
       Change=percent(c(-0.0239, -0.0216, 0.021, 
            -0.0219, -0.0248, -0.0399))) 
DF 

formattable(DF, list(
    Name=formatter(
    "span", 
    style = x ~ ifelse(x == "Technology", 
         formattable::style(font.weight = "bold"), NA)), 
    Value = color_tile("white", "orange"), 
    Change = formatter(
    "span", 
    style = x ~ formattable::style(color = ifelse(x < 0 , "red", "green")), 
    x ~ icontext(ifelse(x < 0, "arrow-down", "arrow-up"), x))) 
) 

``` 

如何在我的ioslides_presentation中获得相同的表格外观?

+0

它只是表的宽度打扰你吗?然后你可以添加'' –

+0

我看不到那里箭头向下/箭头向上... – martinkabe

回答

0

添加以下样式:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 

你也可以把它本地可用,因为即使你在YAML头使用self_contained: true上述解决方案将需要一个网络连接。

+0

它在R工作室内工作,但不在外面。从knitr报告的HTML网站中仍然缺少arrow-down/arrow-up。 – martinkabe

+0

你说得对。没有检查。另外包括一个引导资源... –

+0

完美,现在它好多了。我怎样才能减少表中的字体大小? 我应该添加什么? martinkabe