If it helps you:
##################################################################
## textable - 13.09.2000
##################################################################
"textable" <-
function(matrix, precision=2, column=NULL, caption=NULL, label=NULL,
title="b",
stretch=NULL,
centering="c")
{
ncols <- ncol(matrix)
if (length(centering) == 1) {
if(centering != "r" && centering != "l"
&& centering != "c")
stop("la centering deve essere r, l, c")
ausr <- rep(centering, length = ncols + 1)
}
else {
if (length(centering) == ncols + 1)
ausr <- centering
else
stop("centering ad hoc")
}
exact <-
function(x, prec) {
x <- round(x, prec)
for (i in prec:1) {
if ((i == prec) & ((x * 10^prec) %% (10^prec) == 0))
return(cat(" & ", x, ".", rep(0,
prec), sep = ""))
else if (round((x * 10^prec) %% (10^i), 5) == 0)
return(cat(" & ", x, rep(0, i), sep =
""))
}
return(cat(" & ", x, sep = ""))
}
printout <- function(matrix, precision)
{
for (i in 1:nrow(matrix)) {
for (j in 1:ncol(matrix)) {
exact(matrix[i, j], prec = precision)
}
cat("\\\\ \n")
}
}
cat("\\begin{table}[ht]\n\\begin{center}\n")
if (title == "a" && !is.null(caption))
{
if(length(stretch) == 2)
cat("\\renewcommand{\\baselinestretch}{", stretch[1],
"} \\normalsize\n", sep = "")
cat("\\caption{", sep = "")
if(!is.null(label)) cat("\\label{", label, "}", sep
= "")
cat(caption, "}\n", sep = "")
}
if(length(stretch) == 2)
cat("\\renewcommand{\\baselinestretch}{", stretch[2],
"} \\normalsize\n\\vspace{0.3cm}\n", sep = "")
cat("\\begin{tabular}")
cat("{",ausr[1],"|",ausr[2:length(ausr)],"}\n",
sep = "")
if (is.null(column))
cat("", paste(1:ncols), sep=" & Col ")
else
for (i in 1:ncols) cat("&",column[i])
cat("\\\\\n")
cat("\\hline\n")
printout(matrix = matrix,precision = precision)
cat("\\hline\n")
cat("\\end{tabular}\n")
if (title == "b" && !is.null(caption)) {
if(length(stretch) == 2)
cat("\\renewcommand{\\baselinestretch}{", stretch[1],
"} \\normalsize\n", sep = "")
cat("\\caption{")
if(!is.null(label)) cat("\\label{", label, "}", sep
= "")
cat(caption, "}\n", sep = "")
}
cat("\\end{center}\n\\end{table}\n")
}
##################################################################
## <EoF> textable - 13.09.2000
##################################################################
X<-cbind(c(10,12,13,11),c(20,25,24,22),c(50,45,54,58))
> X
[,1] [,2] [,3]
[1,] 10 20 50
[2,] 12 25 45
[3,] 13 24 54
[4,] 11 22 58> textable(X)
\begin{table}[ht]
\begin{center}
\begin{tabular}{c|ccc}
& Col 1 & Col 2 & Col 3\\
\hline
& 10.00 & 20.00 & 50.00\\
& 12.00 & 25.00 & 45.00\\
& 13.00 & 24.00 & 54.00\\
& 11.00 & 22.00 & 58.00\\
\hline
\end{tabular}
\end{center}
\end{table}
Best, isaia.
"Jeff D. Hamann" wrote:
> Is it possible to write the output/results (redirect) to a latex file?
>
> Jeff.
>
> Jeff D. Hamann
> Hamann, Donald & Associates, Inc.
> PO Box 1421
> Corvallis, Oregon USA 97339-1421
> Bus. 541-753-7333
> Cell. 541-740-5988
> jeff_hamann at hamanndonald.com
> www.hamanndonald.com
>
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Ennio D. Isaia
~ Dep. of Statistics & Mathematics, University of Torino
~ Piazza Arbarello, 8 - 10128 Torino (Italy)
~ Phone: +39 011 670 62 51 ~~ Fax: +39 011 670 62 39
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._