[R] xtable: Width of Columns

Michael Dewey lists at dewey.myzen.co.uk
Fri Mar 3 12:42:25 CET 2017


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

On 02/03/2017 12:39, G.Maubach at 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 at 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.
>

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



More information about the R-help mailing list