[R] Printing a matrix in latexVerbatim without rownames.
Duncan Mackay
dulcalma at bigpond.com
Sat Feb 15 09:44:43 CET 2014
The original has not reached me yet
latexVerbatim is in Hmisc and appears similar to xtable::xtable
using xtable
library(xtable)
x <- matrix(rnorm(25), 5,5,dimnames=list(c(1:5),LETTERS[1:5]))
x
fhtml <- "latex.tex"
file.create(fhtml)
# open to append
ff <- file(fhtml, "a+")
writeLines(print(
xtable(x ),
type = "latex",
tabular.environment = "tabular",
include.rownames = FALSE,
include.colnames = FALSE,
only.contents = TRUE,
hline.after = NULL
), ff)
close(ff)
see ?xtable for formatting + more to suit your requirements
also have a look at dcolumn in latex
>From David Carlisle creator of dcolumn
\makeatletter
\newcolumntype{Y}[4]{>{\color{#1}\DC@{#2}{#3}{#4}}c<{\DC at end}}
\makeatother
and for the column specification
Y{black}..{-1}
which takes a variable decimal format rather than a fixed dcolumn one
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of David Winsemius
Sent: Saturday, 15 February 2014 14:28
To: Gil Gamesh
Cc: r-help at r-project.org
Subject: Re: [R] Printing a matrix in latexVerbatim without rownames.
On Feb 13, 2014, at 2:07 PM, Gil Gamesh wrote:
> Hi,
>
> I'm printing a bunch of summary tables to a latex file using latexVerbatim
> from the Hmisc package.
>
> An example looks like this...
>
>> x
> Visit N Min. 1st Qu. Median Mean 3rd Qu. Max. NAs
> [1,] 1 92 25 27.28 29.05 29.47 31.75 34.8 0
You should post dput(x)
>
>
> And I'm using commands like this...
>
> w<-latexVerbatim(x, file="SummaryTables.tex", append=TRUE)
>
> My question is, can I lose the row label "[1,]"? I've tried using
> rowname=NULL as per the help page for latexVerbatim, but to no effect.
That is how R prints matrix objects. Perhaps you could convert to a
dataframe and suppress rownames. But knowing whether that is effective would
be facilitated by following the advice to post a reproducible example.
>
> Maybe there's a way to use rownamesTexCmd to delete the rownames?
>
> Many thanks,
>
> Gil
>
> [[alternative HTML version deleted]]
Please post in plain text.
>
> ______________________________________________
> 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.
David Winsemius
Alameda, CA, USA
______________________________________________
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.
More information about the R-help
mailing list