[R] nice report generator?

Nutter, Benjamin NutterB at ccf.org
Wed Dec 7 21:18:56 CET 2011


With any sort of reproducible report, you'll have to 'manually place' all of the tables and figures at least once.  If done well, however, you'll only have to ever do it once.  

I'm not an Sweave expert (yet, regrettably), but using lazyWeave, you could generate a customized ANOVA table using the code below.  If you're familiar with Sweave, I'd recommend using it.



library(lazyWeave)
#*** Function to produce the latex code for an ANOVA table
anova.table <- function(aov.object, caption="", ...){
  out <- data.frame(Source = rownames(anova(aov.object)),
                    SS = anova(aov.object)[, 2],
                    D.F. = anova(aov.object)[, 1],
                    stringsAsFactors=FALSE)
  out$MS <- out$SS / out$D.F.
  out$F <- NA
  out$F[-nrow(out)] <- out$MS[-nrow(out)] / out$MS[nrow(out)]
  out$p <- 1 - pf(out$F, out$D.F., out$D.F.[nrow(out)])
  
  out <- rbind(out, data.frame(Source = "Total", SS=sum(out$SS), D.F.=sum(out$D.F.), MS=NA, F=NA, p=NA))
  
  out$SS <- round(out$SS, 3)
  out$MS <- round(out$MS, 3)
  out$F <- round(out$F, 3)
  
  rownames(out) <- NULL
  out[is.na(out)] <- ""
  paste(lazy.table(colnames(out), rborder=c(0, 0, 1), open=TRUE, close=FALSE, caption=caption),
        lazy.table(out, rborder=2, open=FALSE, close=TRUE), sep="\n")
}

#***
#*** Analysis of Variance
m1 <- aov(mpg ~ cyl, data=mtcars)


#***
#*** Write the result to a file
lazy.write(
  lazy.file.start(),
  anova.table(m1, caption="An example ANOVA table from the dataset \\tt mtcars\\rm."),
  lazy.file.end(),
  OutFile="TestFile.tex")

lazy.build("TestFile.tex")

  Benjamin Nutter |  Biostatistician     |  Quantitative Health Sciences
  Cleveland Clinic    |  9500 Euclid Ave.  |  Cleveland, OH 44195  | (216) 445-1365



-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Sarah Goslee
Sent: Wednesday, December 07, 2011 2:34 PM
Cc: r-help; Janko Thyson
Subject: Re: [R] nice report generator?

On Wed, Dec 7, 2011 at 1:50 PM, Michael <comtech.usa at gmail.com> wrote:
> Thanks a lot!
>
> Typically the console output will be something like this:
>
> Analysis of Variance Table
>
> Response: as.double(my.delta)
>             Df Sum Sq Mean Sq F value Pr(>F) my.factor    1      0   
> 0.005   2e-04  0.988 Residuals  1484  32630  21.988
>
> I am looking for a report-generator to make this look nicer and tabularize it...
>
> It doesn't matter if the outputs are in HTML, PDF, etc.
>
> As long as it looks fantastic, that's what we are looking for ... and 
> also the convenience is important... we dont' want to create Latex 
> document with manual insertaion of tables and plots... These need 
> automation... thx a lot!

That's what sweave is *for* - automation and reproducible research. It takes care of the heavy lifting of generating and inserting tables and figures.

You will almost certainly need some tweaking to match your own definition of "looks fantastic" though.

Sarah

>> On 07.12.2011 19:19, Sarah Goslee wrote:
>>> Sweave.
>>>
>>> Or ODFWeave, if Sweave/LaTeX are too much overhead.
>>>
>>> But really, it depends on what kind of report output you need to 
>>> deliver. Printed? HTML? PDF?
>>>
>>> Sarah
>>>
>>> On Wed, Dec 7, 2011 at 1:14 PM, Michael<comtech.usa at gmail.com>  wrote:
>>>> Hi all,
>>>>
>>>> I am looking for recommendations/pointers about best report 
>>>> generator you think that are currently available?
>>>>
>>>> i.e. the package that can help turn console output into 
>>>> nice-looking neat report to send to bosses?
>>>>
>>>> thanks a lot!
>>>> .
>>>



--
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
R-help at 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.


===================================

 Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S.News & World Report (2010).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{dropped:13}}



More information about the R-help mailing list