[R] xtable: Width of Columns

G.Maubach at weinwolf.de G.Maubach at weinwolf.de
Thu Mar 2 13:39:49 CET 2017


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]]



More information about the R-help mailing list