R - 我是否需要使用 print() 添加显式换行符?
如何在 R 中使用换行符?
myStringVariable <- "Very Nice ! I like";
myStringVariabel <- paste(myStringVariable, "\n", sep="");
上面的代码不起作用
PS 在谷歌搜索此类内容时存在重大挑战,因为查询“R new line character”似乎确实让谷歌感到困惑。我真的希望 R 有一个不同的名字。
How do I use the new line character in R?
myStringVariable <- "Very Nice ! I like";
myStringVariabel <- paste(myStringVariable, "\n", sep="");
The above code DOESN'T work
P.S There's significant challenges when googling this kind of stuff since the query "R new line character" does seem to confuse google. I really wish R had a different name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
R 的本质意味着当您简单地打印字符向量时,您永远不会在字符向量中出现换行符。
也就是说,换行符位于字符串中,只是不会将其打印为新行。但是,如果您想打印它们,可以使用其他函数,例如 猫:
The nature of R means that you're never going to have a newline in a character vector when you simply print it out.
That is, the newlines are in the string, they just don't get printed as new lines. However, you can use other functions if you want to print them, such as cat:
您还可以使用
writeLines
。还有:
You can also use
writeLines
.And also:
NewLine Char 示例:
结果:
Example on NewLine Char:
Result: