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 Sal Median COD PRD LowerCI UpperCI
RES I 9683 578 0.9533 29.69 1.191 0.9382 0.9582
RES V 4003 155 0.9763 16.51 1.091 0.9499 0.9943
OTHER 1542 10 0.8367 82.35 1.253 0.4759 2.2293
COM I 1711 26 0.9521 26.01 1.102 0.7811 0.9789
COM 9 1 0.9313 0.00 1.000 0.0000 0.0000
library(R2HTML)
HTMLStart(outdir="c:/R/reports", file="myreport1",
extension="html", echo=FALSE, HTMLframe=TRUE)
HTML(srtype)
HTMLhr()
HTMLStop()
Par Sal Median COD PRD LowerCI UpperCI
RES I 9683.00 578.00 0.95 29.69 1.19 0.94 0.96
RES V 4003.00 155.00 0.98 16.51 1.09 0.95 0.99
OTHER 1542.00 10.00 0.84 82.35 1.25 0.48 2.23
COM I 1711.00 26.00 0.95 26.01 1.10 0.78 0.98
COM V 9.00 1.00 0.93 0.00 1.00 0.00 0.00
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="<tr><td>",
tablend="</table>",header="<html><body>",
trailer="</body></html>")
Now have a look at the file "srtype.html".
Jim
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()
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 Sal Median COD PRD LowerCI UpperCI
RES I 9683 578 0.9533 29.69 1.191 0.9382 0.9582
RES V 4003 155 0.9763 16.51 1.091 0.9499 0.9943
OTHER 1542 10 0.8367 82.35 1.253 0.4759 2.2293
COM I 1711 26 0.9521 26.01 1.102 0.7811 0.9789
COM 9 1 0.9313 0.00 1.000 0.0000 0.0000
library(R2HTML)
HTMLStart(outdir="c:/R/reports", file="myreport1",
extension="html", echo=FALSE, HTMLframe=TRUE)
HTML(srtype)
HTMLhr()
HTMLStop()
Par Sal Median COD PRD LowerCI UpperCI
RES I 9683.00 578.00 0.95 29.69 1.19 0.94 0.96
RES V 4003.00 155.00 0.98 16.51 1.09 0.95 0.99
OTHER 1542.00 10.00 0.84 82.35 1.25 0.48 2.23
COM I 1711.00 26.00 0.95 26.01 1.10 0.78 0.98
COM V 9.00 1.00 0.93 0.00 1.00 0.00 0.00
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
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
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 Sal Median COD PRD LowerCI UpperCI
RES I 9683 578 0.9533 29.69 1.191 0.9382 0.9582
RES V 4003 155 0.9763 16.51 1.091 0.9499 0.9943
OTHER 1542 10 0.8367 82.35 1.253 0.4759 2.2293
COM I 1711 26 0.9521 26.01 1.102 0.7811 0.9789
COM 9 1 0.9313 0.00 1.000 0.0000 0.0000
library(R2HTML)
HTMLStart(outdir="c:/R/reports", file="myreport1",
extension="html", echo=FALSE, HTMLframe=TRUE)
HTML(srtype)
HTMLhr()
HTMLStop()
Par Sal Median COD PRD LowerCI UpperCI
RES I 9683.00 578.00 0.95 29.69 1.19 0.94 0.96
RES V 4003.00 155.00 0.98 16.51 1.09 0.95 0.99
OTHER 1542.00 10.00 0.84 82.35 1.25 0.48 2.23
COM I 1711.00 26.00 0.95 26.01 1.10 0.78 0.98
COM V 9.00 1.00 0.93 0.00 1.00 0.00 0.00
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
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.