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 -------------- next part -------------- A non-text attachment was scrubbed... Name: sample_table.pdf Type: application/pdf Size: 26796 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200507/3e183657/attachment.pdf>
What are you doing? http://adv-r.had.co.nz/Reproducibility.html http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example On Fri, 8 May 2020 at 10:50, aiguo li via R-help <r-help at 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 at 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. >-- John Kane Kingston ON Canada [[alternative HTML version deleted]]
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 at 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 at 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.
Hi again, Oops, you'll need the images as well. Save the HTML file and images to the same directory. Jim On Sat, May 9, 2020 at 9:24 PM Jim Lemon <drjimlemon at gmail.com> wrote:> > 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 at 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 at 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.-------------- next part -------------- A non-text attachment was scrubbed... Name: Pathway1.png Type: image/png Size: 169 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200509/3837b0d1/attachment.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: Pathway2.png Type: image/png Size: 167 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200509/3837b0d1/attachment-0001.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: Pathway3.png Type: image/png Size: 168 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200509/3837b0d1/attachment-0002.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: Pathway4.png Type: image/png Size: 170 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20200509/3837b0d1/attachment-0003.png>