Hi.

You should check function addtable2plot from plotrix package.

Also, here is an example of modified addtable2plot function that I
sometimes use.
This function is probably to far from perfect but, maybe, it will give you
some ideas how to solve your problem:

t2p <- function(x=par("usr")[1],y= par("usr")[4],
                table, cex=par("cex"), bg=par("bg"), text.col=par("fg"))
{
plot(1,type="n", axes=F, xlab="", ylab="")
column.names<-colnames(table)
mwidth<-strwidth("M",cex=cex)
cellwidth <- max(strwidth(c(column.names,
             as.vector(unlist(table))),cex=cex))+mwidth
cellheight <- max(strheight(c(column.names,as.vector(unlist(table))),
              cex=cex))*1.5
tabdim<-dim(table)

xleft <- x
ytop <- y

for(row in 1:tabdim[1])
 {
for(column in 1:tabdim[2])
   {
if(row==1) par(font=4) else
par(font=1)
   rect(xleft+(column-0.9)*cellwidth,
        ytop-(row-0.9)*cellheight,
        xleft+(column)*cellwidth,
        ytop-row*cellheight,
        col=bg[row,column],border=NA)
   text(xleft+(column-0.45)*cellwidth,
        ytop-(row-0.45)*cellheight,
        table[row,column],cex=cex,col=text.col)
    }
 }
}
DF <- data.frame(x1=1:5, x2=5:1, x3=rep(1,5), x4=rep(5,5))
DF1 <- rbind(names(DF), DF)
mat <-  matrix(NA,ncol=ncol(DF), nrow=nrow(DF1)+1)
mat[1,] <- "lightblue"
mat[seq(2,nrow(mat),2), ] <- "gray"
mat[seq(3,nrow(mat),2), ] <- "white"

t2p(table=DF1, bg=mat)
t2p(table=DF1, bg=mat, x=0.7, y=1.2)

As you can see t2p function has some arguments that you can play with in
order to get better formatted table.
After plotting a table you can save it as bitmap.

I hope this helps.

Andrija



On Tue, Jul 17, 2012 at 9:11 PM, jcrosbie <ja...@crosb.ie> wrote:

> I would like to output a nicely formatted data frame to a bitmap.
>
> Is this possible in R?
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Table-Frame-output-tp4636790.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to