[R] Presentation tables in R (knitr)

Franzini, Gabriele [Nervianoms] Gabriele.Franzini at nervianoms.com
Wed Nov 26 13:35:01 CET 2014


I found also knitr + html + the ReporteRs package a good combination,
and less intimidating than Latex. Have a look at their FlexTable tool.

HTH,
Gabriele  


-----Original Message-----
From: Tom Wright [mailto:tom at maladmin.com] 
Sent: Tuesday, November 25, 2014 9:12 PM
To: r-help at r-project.org
Subject: [R] Presentation tables in R (knitr)

Hi,
This problem has me stumped so I thought I'd ask the experts. I'm trying
to create a pretty summary table of some data (which patients have had
what tests at what times). Ideally I'd like to knitr this into a pretty
PDF for presentation.
If anyone has pointers I'll be grateful.

require(tables)
require(reshape2)

data<-data.frame('ID'=paste0('pat',c(rep(1,8),rep(2,8))),
                 'Time'=c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4),
                 'Eye'=rep(c('OS','OS','OD','OD'),4),
                 'Measure'=rep(c('Height','Weight'),8))

tabular(Measure~factor(ID)*factor(Time)*factor(Eye),data)
#All levels of Time are repeated for all IDs, I'd prefer to just show
the relevant times.

tabular(Measure~factor(ID)*Time*factor(Eye),data)
#Time is getting collapsed by ID

data$value=1
dcast(data,Measure~ID+Time+Eye)
#close but not very pretty



More information about the R-help mailing list