Dieter Menne wrote: > I tried to create an ftable lookalike of the following data set in > LaTeX/Sweave
> with summary(formula,..), but I could not get it to work for count tables; > numeric tables work fine. > summary(formula,...,fun="table") does not give the full cross breakdown. Frank E Harrell Jr <f.harrell <at> vanderbilt.edu> writes: > See if fun=table (no quotes) or method='cross' work for you. > Frank The ftable-type-lookalike looks more extensible to me, as it works for any reasonable number of columns/rows. Here my quick and dirty version for Sweave (no file output, fixed, to ctable) if someone else needs it. Dieter #------------------------- latex.ftable = function(object,title="",caption,label,pos="htbp",...){ # use default formatting of ftable as a starter ft = format(object,quote=FALSE) cv = attr(object,"col.vars") rv = attr(object,"row.vars") nr = nrow(ft) nc = ncol(ft) ncolvars = length(cv) nrowvars = length(rv) ft[ncolvars,1:nrowvars] = ft[ncolvars+1,1:nrowvars] align1 = paste(rep("l",ncolvars),collapse="") align2 = paste(rep("r",nc-ncolvars),collapse="") cat("\\ctable[ caption={",caption,"}, label=",label,",pos=",pos, ", botcap]{", align1,align2,"}{} \n{\\FL\n", sep="") for (i in 1:ncolvars){ head = paste("\\multicolumn{1}{c}{",ft[i,],"}",collapse="&\n",sep="") if (i == ncolvars) cat(head, "\n\\ML\n") else cat(head, "\n\\NN\n") } for (i in (ncolvars+2):nr) { cat(paste(ft[i,],collapse="&")) if (i != nr ) { if (substr(ft[i,1],1,1) ==' ' & substr(ft[i+1,1],1,1) !=' '){ cat("\\ML\n") } else cat("\\NN\n") } } cat("\n\\LL\n}\n") } ______________________________________________ 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.