相关疑难解决方法(0)

将迷你图表添加到表格中

我试图将我的所有数据运算转移到Rmarkdown而不是SPSS + Excel,但无法弄清楚如何创建带有附加图的表.

理想的桌子

在Excel中,这可以使用迷你图功能完成,或者像我一样,只需创建一个图表并非常准确地放置它.

上表是使用Tables包(和Pander)中的表格函数创建的.并粘贴到Excel中以创建图形(以及图形的标题).

library(tables)
library(pander)
pander( #convert table to rmarkdown table
  tabular( 
  (Species + 1) ~ (n=1) + Format(digits=2) *
         (Sepal.Length + Sepal.Width) * (mean + sd), 
  data = iris),
  caption = "Table 1. Iris") #Heading for table
Run Code Online (Sandbox Code Playgroud)

有没有人创造过这样的东西?也许使用gridExtra包解决方法,虽然我怀疑包可以匹配表和图.


编辑 - 迄今为止的解决方案.
HTML已完成.在那里用pdf中途.对于doc,我认为不可能(复制粘贴到Excel).

HTML表
首先,所以R知道我是否正在渲染html,pdf或doc.out_type取值:"html","pdf"和"docx".我可以在if语句中使用这个对象.

out_type <- knitr::opts_knit$get("rmarkdown.pandoc.to")
Run Code Online (Sandbox Code Playgroud)

现在吧:

    if(out_type == "html"){ #if output is html then:
        my_table$Mean_Sepal_Length <- paste0( #I have a table saved as a dataframe. I add a column to it called Mean_Sepal_Length
"<span style=' …
Run Code Online (Sandbox Code Playgroud)

r graph sparklines knitr r-markdown

11
推荐指数
2
解决办法
3356
查看次数

标签 统计

graph ×1

knitr ×1

r ×1

r-markdown ×1

sparklines ×1