Re: [R] R2HTML Report number format, or Better Way?
Hi L.A., Use the package 'hwriter' to produce HTML pages/objects. library(hwriter) hwrite(srtype, page=c:/R/reports/myreport1.html) 'hwrite' can be combined with the function 'format' (to manage number format, digits, decimal places, etc...) and supports advanced HTML/CSS formatting options. Best regards, Greg --- Gregoire Pau EMBL Research Officer http://www.ebi.ac.uk/~gpau/ L.A. wrote: Here I am again with question I'll feel foolish for asking, when I see the answer. I'm trying to produce a report and here's where I get stuck: How do I get R2HTML to produce the same number format? Particularly remove the decimal places for Par and Sal. Are there better methods to produce this type of report? Thanks, L.A. R version 2.10.0 XP srtype-cbind(Par,Sal,Median,COD,PRD,LowerCI,UpperCI) srtype Par SalMedian COD PRD LowerCI UpperCI RES I 9683 578 0.9533 29.69 1.191 0.9382 0.9582 RES V4003 155 0.9763 16.51 1.091 0.9499 0.9943 OTHER 1542100.8367 82.35 1.253 0.4759 2.2293 COM I1711260.9521 26.01 1.102 0.7811 0.9789 COM 9 10.93130.00 1.000 0. 0. library(R2HTML) HTMLStart(outdir=c:/R/reports, file=myreport1, extension=html, echo=FALSE, HTMLframe=TRUE) HTML(srtype) HTMLhr() HTMLStop() ParSal Median CODPRD LowerCI UpperCI RES I 9683.00 578.00 0.95 29.69 1.19 0.940.96 RES V4003.00 155.00 0.98 16.51 1.09 0.950.99 OTHER 1542.00 10.000.84 82.35 1.25 0.482.23 COM I1711.00 26.000.95 26.01 1.10 0.780.98 COM V9.001.00 0.93 0.00 1.00 0.00 0.00 __ 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.
Re: [R] R2HTML Report number format, or Better Way?
Thanks, All Jim your solution works and I'm playing around with it trying to learn the ins outs I'd still like to figure out how to get this to work in R2HTML. I think I worded my question wrong making it appear more difficult, so I'll Try again. Here is the data and code Par-9683 sal-578 M-.9533 C-29.69 srtype-cbind(Par,sal,M,C) srtype Par sal M C [1,] 9683 578 0.9533 29.69 library(R2HTML) HTMLStart(outdir=c:/R/reports, file=myreport1, extension=html, echo=FALSE, HTMLframe=TRUE) HTML(srtype) HTMLhr() HTMLStop() R outputParsalMC 9683.00 578.00 0.95 29.69 I just want to format the R2HTML output to produce this: R outputParsalMC 9683 578 0.95 29.69 Thanks again to everyone. L.A. -- View this message in context: http://n4.nabble.com/R2HTML-Report-number-format-or-Better-Way-tp997787p998348.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.
Re: [R] R2HTML Report number format, or Better Way?
On 01/04/2010 03:36 AM, L.A. wrote: Here I am again with question I'll feel foolish for asking, when I see the answer. I'm trying to produce a report and here's where I get stuck: How do I get R2HTML to produce the same number format? Particularly remove the decimal places for Par and Sal. Are there better methods to produce this type of report? Hi L.A., Try this: # la1.dat is a text file with your sample data srtype-read.table(la1.dat,header=TRUE) # I don't know where the rownames came from # so I added them rownames(srtype)- c(RES I,RES V,OTHER,COM I,COM) library(prettyR) delim.table(srtype,srtype.html,delim=td, tabegin=table border=0,bor=trtd, tablend=/table,header=htmlbody, trailer=/body/html) Now have a look at the file srtype.html. Jim __ 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.
Re: [R] R2HTML Report number format, or Better Way?
L.A. wrote: Here I am again with question I'll feel foolish for asking, when I see the answer. I'm trying to produce a report and here's where I get stuck: srtype-cbind(Par,Sal,Median,COD,PRD,LowerCI,UpperCI) srtype Chances are better to get a reply when you supply the data as code as in the example below Maybe Eric Lecoutre could have a look at it. Dieter srtype=data.frame(Par=as.numeric(1000:1005), Sal=as.numeric(1:6),Median=rnorm(6)) srtypeM = as.matrix(srtype) library(R2HTML) HTMLStart(outdir=c:/tmp, file=myreport1, extension=html, echo=FALSE, HTMLframe=TRUE) # Use a data frame: will make column-wise decisions HTML(srtype) # When you have a matrix... HTML(srtypeM) # ... using the format arguments should work, but # I think this might be a bug, because only the first # in the vector is used. HTML(srtypeM,nsmall=c(1,5,7),digits=c(2,9,10)) # Same happens in the examples on the doc page HTML(iris[1:2,1:2],nsmall=c(2,5)) HTMLhr() HTMLStop() -- View this message in context: http://n4.nabble.com/R2HTML-Report-number-format-or-Better-Way-tp997787p997914.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.
Re: [R] R2HTML Report number format, or Better Way?
Thanks for the replys. I've played with both suggestions, but must not understand as I could not get them to work. In the first, do I have to save my results as a *.dat file? Where do I find the HTML file? For the second, As a beginner, is this what you mean by supply the data as code? The actual data is 17000 rows and 31 columns. L.A. Par-by(Dataset[ , ACCOUNTNO], Dataset[TYPE], length) Sal-by(Dataset[ , ratio], Dataset[TYPE], length) PRD-with(Dataset, by(Dataset[ , prdb], TYPE, max)) COD-with(Dataset, by(Dataset[ , coda], TYPE, max)) LowerCI-with(Dataset, by(Dataset[ , LLCI], TYPE, max)) UpperCI-with(Dataset, by(Dataset[ , UUCI], TYPE, max)) srtype-cbind(Parcels,Sales,Median,COD,PRD,LowerCI,UpperCI) srtype Par SalMedian COD PRD LowerCI UpperCI RES I 9683 578 0.9533 29.69 1.191 0.9382 0.9582 RES V4003 155 0.9763 16.51 1.091 0.9499 0.9943 OTHER 1542100.8367 82.35 1.253 0.4759 2.2293 COM I1711260.9521 26.01 1.102 0.7811 0.9789 COM 9 10.93130.00 1.000 0. 0. library(R2HTML) HTMLStart(outdir=c:/R/reports, file=myreport1, extension=html, echo=FALSE, HTMLframe=TRUE) HTML(srtype) HTMLhr() HTMLStop() ParSal Median CODPRD LowerCI UpperCI RES I 9683.00 578.00 0.95 29.69 1.19 0.940.96 RES V4003.00 155.00 0.98 16.51 1.09 0.950.99 OTHER 1542.00 10.000.84 82.35 1.25 0.482.23 COM I1711.00 26.000.95 26.01 1.10 0.780.98 COM V9.001.00 0.93 0.00 1.00 0.00 0.00 -- View this message in context: http://n4.nabble.com/R2HTML-Report-number-format-or-Better-Way-tp997787p997974.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.
Re: [R] R2HTML Report number format, or Better Way?
On 01/04/2010 10:49 AM, L.A. wrote: Thanks for the replys. I've played with both suggestions, but must not understand as I could not get them to work. In the first, do I have to save my results as a *.dat file? No, I simply showed how I obtained the data frame that you gave as an example. Where do I find the HTML file? The HTML file will be in the current R directory. If you include a valid path in the filename argument, it will be wherever you specify. The delim.table function formats the result in whatever way the object would normally be printed and is usually called in an R script that is to have HTML output produced by the htmlize function. Jim __ 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.
Re: [R] R2HTML Report number format, or Better Way?
L.A. wrote: For the second, As a beginner, is this what you mean by supply the data as code? The actual data is 17000 rows and 31 columns. In your case, it is irrelevant if the data are 17000x31 or 2x3, so an example with few columns is sufficient. And if you supply the data in code, other people can copy it to provide a tested example. See my example, or simply (not tested) df = matrix(c(1,2,0.3,0.4,nrow=2) As a test, go to another computer and let you sample run there? Does is complain object not found? Dieter -- View this message in context: http://n4.nabble.com/R2HTML-Report-number-format-or-Better-Way-tp997787p998085.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.