如何在R编程中为多个页面创建标题和脚注?在RTF或PDF中

时间:2014-12-12 08:52:06

标签: r

#Report Section

output<-"D:/R/Reference program for R/Table_EG_chg.doc" # although this is RTF, we can use the

rtf<-RTF(output,width=8.5,height=11,font.size=9,omi=c(0.5,0.5,0.5,0.5)) 


addHeader(rtf,title = " Table14.3.2.3.1", subtitle =" Vital Signs - Absolute Values", font.size=9,TOC.level=0)

addTable(rtf,final,font.size=9,row.names=FALSE,NA.string="0",col.justify='L',header.col.justify='L',col.widths=c(1.75,1.5,1.25,0.5,0.5,0.5,0.5,0.5,0.5))
addTable(rtf,as.data.frame(head(iris)),font.size=10,row.names=FALSE,NA.string="-")
addText(rtf, "\n\n", bold=TRUE, italic=FALSE)

done(rtf) # writes and closes the file

final是我需要在RTF输出中打印的数据框。

这是我用于在RTF中创建输出的代码。它仅对第一页起作用,因为页面输出的其余部分在所有页面中都没有标题和脚注。请允许任何人使用此方法,如果是这样,请您发送代码......

这很容易在SAS中完成。我在R.中需要它   任何人都有这个答案.....

2 个答案:

答案 0 :(得分:0)

想想您问的清单,我们在SAS编程中可以做什么,我尝试使用R程序并获得了输出。请找到以下代码,我使用了虚拟数据集和应用的逻辑,您需要获取rtf文档,在此我们可以在多个页面中查看标题和脚注。

com.segment.analytics.android:analytics:4.3.0,

enter image description here

答案 1 :(得分:0)

@Jaikumar 抱歉,我们花了 6 年时间才推出一个最终可以满足您要求的软件包。去年年底,发布了reporter 包。这个包复制了 SAS proc 报告的许多功能。它可以做数据集列表,就像 SAS 一样。它会在每一页上重复标题和脚注,而无需做任何特别的事情。下面是一个例子:

library(reporter)
library(magrittr)


# Create table
tbl <- create_table(iris) %>% 
  titles("Sample Title for Iris Data") %>% 
  footnotes("My footnote")

# Create report and add table to report
rpt <- create_report("test.rtf", output_type = "RTF") %>% 
  add_content(tbl)


# Write the report
write_report(rpt)

它还可以以 RTF、PDF 和 TXT 格式打印。要使用 PDF,只需更改文件名和 output_type。