这个问题在这里已经有了答案:
Printing newlines with print() in R
(4 个回答)
7年前关闭。
使用打印功能打印到屏幕时,我希望一行出现在一行上,而下一行出现在第二行上。
用这条线
print(
paste(
"hey I want this to be line one", "and this to be line two", "would be great if you could help"
)
)
我想要这个打印
[1]“嘿,我希望这是第一行
[2] 如果你能帮忙的话,这是第二行就好了”
最佳答案
我假设您的示例输出实际上应该是三行而不是两行...您应该使用 cat
而不是 print
,并添加 sep="\n"
到 paste
陈述:
cat(paste("hey I want this to be line one",
"and this to be line two",
"would be great if you could help" ,sep="\n"))
输出:
hey I want this to be line one
and this to be line two
would be great if you could help
关于r - 在 R 中的打印语句中添加换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24072315/