Hi Aiguo
Just for fun, I tried to work out what you wanted. I think you are
looking for a function that creates a horizontal stacked bar image of
a logical vector:

TFbar<-function(x,file="TFbar",grDev="png",width=100,height=25,
 col=c("green","red")) {

 do.call(grDev,
  list(file=paste(file,grDev,sep="."),width=width,height=height))
 par(xaxs="i",mar=c(0,0,0,0))
 plot(0,xlim=c(1,width),ylim=c(1,height),type="n",axes=FALSE)
 Twidth<-width*sum(x)/length(x)
 Fwidth<-width-Twidth
 rect(1,1,Twidth,height,col=col[1])
 rect(Twidth,1,width,height,col=col[2])
 dev.off()
 return(Twidth/width)
}

To instantiate this with your example:

TFnames<-paste0("Pathway",1:4)
for(i in 1:4) {
 assign("x",sample(c(TRUE,FALSE),100,TRUE))
 TFbar(x,TFnames[i])
}
TFtags<-paste0("<img src=",TFnames,".png>")
TFdf<-data.frame(GO_Terms=TFnames,S1=TFtags,stringsAsFactors=FALSE)
library(prettyR)
delim.table(TFdf,filename="TFtable.htm",leading.delim=FALSE,
 label="",html=TRUE,show.rownames=FALSE)

Sadly, I found a bug in delim.table that will be corrected in the next
version. The attached HTML file shows the table you get with the
corrected version.

Jim

On Sat, May 9, 2020 at 12:50 AM aiguo li via R-help
<r-help@r-project.org> wrote:
>
> Hello all,
> I need to make a table with a value imaged by greater than certain value as 
> attached.  Could you give me a suggestions on which R package will be good 
> for this type of table?
> Thanks and stay safe!
> Aiguo______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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