简体   繁体   English

输出多行文本

[英]Outputting multiple lines of text

I have two numeric lists that I would like to output as text in shiny, but I am having difficulty outputting multiple lines. 我有两个数字列表,希望以闪亮的文本形式输出,但是我很难输出多行。 Say the two lists are: 说两个列表是:

violations1 <- c(1,2,3,5)
violations2 <- c(66,354,78)

and for output I would like to see: 对于输出,我希望看到:

Violations of Type 1: 1, 2, 3, 4, 5
Violations of Type 2: 66, 354, 78

but when I use 但是当我使用

paste("Violations of Type 1:", violations1, "Violations of Type 2:", violations2)

I get 我懂了

[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" 

Using collapse option of paste : 使用paste collapse选项:

#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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM