Skip to content

Printing a matrix in latexVerbatim without rownames.

4 messages · Gil Gamesh, Greg Snow, David Winsemius +1 more

#
Have you tried setting all the rownames to be the empty string?  Its a
bit of a kludge, but a simple one.
On Thu, Feb 13, 2014 at 3:07 PM, Gil Gamesh <gamesh.g at gmail.com> wrote:

  
    
#
On Feb 13, 2014, at 2:07 PM, Gil Gamesh wrote:

            
You should post dput(x)
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.
Please post in plain text.
David Winsemius
Alameda, CA, USA
#
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
\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:

            
You should post dput(x)
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.
Please post in plain text.
http://www.R-project.org/posting-guide.html
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.