首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >输出多行文本

输出多行文本
EN

Stack Overflow用户
提问于 2014-12-07 21:11:19
回答 1查看 41关注 0票数 1

我有两个数字列表,我想输出为文本的闪亮,但我有困难输出多行。假设这两份清单是:

代码语言:javascript
复制
violations1 <- c(1,2,3,5)
violations2 <- c(66,354,78)

至于产出,我希望看到:

代码语言:javascript
复制
Violations of Type 1: 1, 2, 3, 4, 5
Violations of Type 2: 66, 354, 78

但当我用

代码语言:javascript
复制
paste("Violations of Type 1:", violations1, "Violations of Type 2:", violations2)

我得到了

代码语言:javascript
复制
[1] "Violations of Type 1: 1 Violations of Type 2: 66" 
[2] "Violations of Type 1: 2 Violations of Type 2: 354"
[3] "Violations of Type 1: 3 Violations of Type 2: 78" 
[4] "Violations of Type 1: 5 Violations of Type 2: 66" 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-12-07 21:34:41

使用collapse选项的paste

代码语言:javascript
复制
#data
violations1 <- c(1,2,3,5)
violations2 <- c(66,354,78)

#result
paste("Violations of Type 1:",paste(violations1,collapse = ","))
#[1] "Violations of Type 1: 1,2,3,5"
paste("Violations of Type 2:",paste(violations2,collapse = ","))
#[1] "Violations of Type 2: 66,354,78"
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27347888

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档