r - 删除 Markdown 输出中的换行符
问题描述
我想将 a 的内容打印data.table
到 R-Studio 的 Markdown 文档中。但是,输出有点宽,所以我减少了字体,如下所述:Code chunk font size in Rmarkdown with knitr and latex
然而,即使将字体减小到很小,尽管有足够的空间让列相邻,但换行符仍然存在。我想知道如何实现这一点。
---
title: "mwe"
output: pdf_document
---
```
{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(data.table)
dat <- data.table(id=1:5,num=31:35,text=c("a","b","c","d","here you can find some long text to artificially widen this text column and demonstrate the problem"))
```
Here is some text.
\tiny
```{r}
dat
```
解决方案
检查?options
并查找width
控制每行打印列数的参数:
---
title: "mwe"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(data.table)
dat <- data.table(id=1:5,num=31:35,text=c("a","b","c","d","here you can find some long text to artificially widen this text column and demonstrate the problem"))
```
\tiny
```{r}
dat
```
```{r}
options(width = 120)
dat
```
推荐阅读
- python - 我想通过麦克风发送我正在计算机上收听的音频
- mysql - 如何将“当前”mysql时间戳值迁移到postgreSQL
- linux - GNU 并行 - 通过多个 ssh 跳转主机运行命令
- c - 当应用于无符号操作数和有符号操作数时,整数除法会产生不同的结果吗?
- c# - C# 使用 count 属性反序列化对象的最佳方法
- java - 如何更改表单字段的颜色,其值已被用户修改?
- laravel - 为什么不能在之前在 laravel 中创建的另一个 api 路由中获取会话?
- amazon-eks - AWS EKS 集群不与密钥管理器连接
- python - 如何将单词列表变成字符串列表?
- python - Python列表仅附加字典