【问题标题】:Wrapped text in tables when knitting to pdf using gtWrapped text in tables when knitting to pdf using gt
【发布时间】:2022-12-02 10:45:17
【问题描述】:

Sorry if this is a very trivial question but I've looked up and down the internet and can't find an answer. I'm making a basic table using the gt package in markdown. But I can't seem to get the text to wrap when knitting to a *.pdf. Any help would be greatly appreciated!

table_data %>% gt()
  • Add a piece of code
  • thanks, any idea on the content of that code though?
  • provide the code for table data
  • @randmlaber why don't you use the example code from gt:: package? e.g.: r # Create a display table showing ten of # the largest islands in the world gt_tbl <- gt(islands_tbl) # Show the gt Table gt_tbl

标签: r-markdown gt


【解决方案1】:

Not an answer, but a reproducible working example.

---
title: "Test"
output: pdf_document
---

```{r test, echo=FALSE, warning = FALSE}
library(tidyverse)
library(gt)

test <- data.frame(v1=c(
  "This is a long string. This is a long string. This is a long string. This is a long string. This is a long string.",
  "This is a another long string. This is a another long string. This is a another long string. This is a another long string. This is a another long string."),
                   v2=c(1, 2))
test %>% gt()
```

results in:

【讨论】:

    猜你喜欢
    • 2022-12-26
    • 2022-12-01
    • 2022-12-27
    • 2022-12-02
    • 2022-12-01
    • 1970-01-01
    • 2022-12-27
    • 2022-12-19
    • 2021-04-17
    相关资源
    最近更新 更多