[R] new to latex to pdf

From: Mike Babyak <mbabyak_at_nc.rr.com>
Date: Sun, 02 Mar 2008 13:51:01 -0500

Dear All,

I'm trying to teach myself latex along with the latex function in Hmisc and have hit a roadblock that I can't seem to get around. I'd greatly appreciate any pointers.

I'm running R 2.6.0 on Windows XP and have Miktex 2.7 installed.

I've reproduced the code below, taken from Frank Harrell's latexsummary introduction. My question relates to getting a pdf version of the table from the following code. The pdfs of the graphics (f1a and f1b) generated by setpdf are fine. However, after a number of attempts using different methods, I don't seem to be able to get a pdf of the table from the s1 object (I see the right table in my previewer just fine). I've tried texi2dvi (texfilename, pdf=T) but get only a series of errors and an unformatted table in the pdf.

I'm sure I'm missing some fundamental concept here, but I'm afraid I'm not seeing it. I'd appreciate if anyone could point me in the right direction. ( I have no trouble writing my own simple latex code and converting it to pdf using pdftex in miktex).


Mike Babyak
Department of Psychiatry and Behavioral Science Duke University Medical Center

Here's the code:


pbc<-upData(pbc, moveUnits=TRUE,
labels=c(stage='Histologic Stage\nLudwig Criteria'))

kmsurv <- function(S, times) {
f <- survfit.km(factor(rep(1,nrow(S))), S)

tt <- c(0, f$time)
ss <- c(1, f$surv) # add first point to survival curve
approx(tt, ss, xout=times, method='constant', f=0)$y


describe.survival <- function(y) {
km <- kmsurv(y, c(2,5))
c('2 Year'=km[1], '5 Year'=km[2], 'Mean, y'=sum(y[,1])/sum(y[,2]))

S <- with(pbc, Surv(fu.days/365.25, status)) s1 <- summary(S ~ age + albumin + ascites + bili + drug + edema + chol, fun=describe.survival, data=pbc)  

for(w in 1:2) {
if(w==1) setpdf(f1a,sublines=1,h=5.25) else setpdf(f1b,sublines=1,h=5)
plot(s1, which=if(w==1)1:2 else 3,
cex.labels=.7, cex.group.labels=.7*1.15, subtitles=T, main='', pch=if(w==2) 16 else c('2','5'), # 16=solid circle xlab=if(w==2)'Survival Time' else 'Survival Probability') dev.off()

w <- latex(s1, cdec=c(2,2,1), ctable=TRUE, caption='Survival')

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. Received on Sun 02 Mar 2008 - 18:54:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 02 Mar 2008 - 19:30:57 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive