创建PDF表格

Tom*_*Tom 33 r

有没有办法从R生成表的PDF,就像生成绘图一样(即使用pdf()或ggsave())?我意识到有其他程序的方法(使用sweave等),但我想从R生产它.

Dir*_*tel 31

是的,因为您可以将文本放入图表中,因此可以放入pdf设备.

最好的包装可能是textplot()Greg Warnes可信赖的gplots包中的功能.以下是其帮助页面的示例部分的开头:

# show R version information
textplot(version)
# show the alphabet as a single string
textplot( paste(letters[1:26], collapse=" ") )

# show the alphabet as a matrix 
textplot( matrix(letters[1:26], ncol=2))

### Make a nice 4 way display with two plots and two text summaries 
data(iris)  
par(mfrow=c(2,2))   
plot( Sepal.Length ~ Species, data=iris, border="blue", col="cyan",   
      main="Boxplot of Sepal Length by Species" )    
plotmeans(Sepal.Length ~ Species, data=iris, barwidth=2, connect=FALSE,
          main="Means and 95\% Confidence Intervals\nof Sepal Length by Species")

info <- sapply(split(iris$Sepal.Length, iris$Species),
               function(x) round(c(Mean=mean(x), SD=sd(x), N=gdata::nobs(x)),2))

textplot( info, valign="top"  )
title("Sepal Length by Species")

reg <- lm( Sepal.Length ~ Species, data=iris )
textplot( capture.output(summary(reg)), valign="top")
title("Regression of Sepal Length by Species")

par(mfrow=c(1,1))
Run Code Online (Sandbox Code Playgroud)


bap*_*ste 15

又见grid.tablegridExtra,使用网格图形.


Gre*_*now 5

plotrix 包中还有 addtable2plot 函数。