On 06/03/2017 07:45, g.maub...@weinwolf.de wrote:
Hi Michael,

thank for you answer.

Where do I have to put the code snippet "p(3cm)"? Is it neither an
official argument to xtable() nor to print.xtable().


From the help about the align argument:

Character vector of length equal to the number of columns of the resulting table, indicating the alignment of the corresponding columns. Also, "|" may be used to produce vertical lines between columns in LaTeX tables, but these are effectively ignored when considering the required length of the supplied vector. If a character vector of length one is supplied, it is split as strsplit(align, "")[[1]] before processing. Since the row names are printed in the first column, the length of align is one greater than ncol(x) if x is a data.frame. Use "l", "r", and "c" to denote left, right, and center alignment, respectively. Use "p{3cm}" etc. for a LaTeX column of the specified width. For HTML output the "p" alignment is interpreted as "l", ignoring the width request. Default depends on the class of x.

Could you give me a hint?

Kind regards

Georg




Von:        Michael Dewey <li...@dewey.myzen.co.uk>
An:        g.maub...@weinwolf.de, r-help@r-project.org,
Datum:        03.03.2017 12:41
Betreff:        Re: [R] xtable: Width of Columns
------------------------------------------------------------------------



Does p{3cm} do what you want as an alignment?

On 02/03/2017 12:39, g.maub...@weinwolf.de wrote:
Hi All,

I have the following code in R Markdown document:

```{r, results = "asis", echo = FALSE}
library(xtable)
response <- as.data.frame(matrix(NA, 2, 2))
colnames(response) <- c("Anzahl", "Prozent")
rownames(response) <- c("gesamte R�cksendungen (brutto)  ",
                        "auswertbare Frageb�gen (netto)  ")
response[[1, 1]] <- 1
response[[1, 2]] <- 2.0
response[[2, 1]] <- 3
response[[2, 2]] <- 4.0

response_table <- xtable(
  response,
  caption = "R�cklauf und R�cklaufquote",
  label = "Responsequote",
  display = c("s","d","f"),
  digits = 1,
  align = c("l", "c", "c") #  auto = TRUE
  )

print.xtable(
  response_table,
  type = "html",
  caption.placement = "top",
  format.args = list(
    big.mark = ".",
    decimal.mark = ","),
  size = 500,
  width = 100)
```

and would like to control the width of the columns. But columns width is
always aligned to the content.

Is there a way to give the columns width, e.g. 25 characters, for all
columns or for each column separately to get more spacing for the text and
the borders of the table?

Kind regards

Georg

                 [[alternative HTML version deleted]]



______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
<http://www.r-project.org/posting-guide.html>
and provide commented, minimal, self-contained, reproducible code.


--
Michael
http://www.dewey.myzen.co.uk/home.html


--
Michael
http://www.dewey.myzen.co.uk/home.html

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to