[英]How to do multiple-line strings in R?
如何使用R在多行上执行字符串,相当于此Python脚本:
string = """
Because I could
Not stop for Death
He gladly stopped for me
"""
对此的上下文是,我有一个非常长的SQL代码,带有一堆换行符和子命令,我想将其作为单个字符串输入以便稍后进行评估,并且手动清理它将很困难。
没有什么特别需要。 只是开头和结尾的引号。
在R:
x = "Because I could
Not stop for Death
He gladly stopped for me"
x
# [1] "Because I could\nNot stop for Death\nHe gladly stopped for me"
cat(x)
# Because I could
# Not stop for Death
# He gladly stopped for me
在Python中:
>>> string = """
... Because I could
... Not stop for Death
... He gladly stopped for me
... """
>>> string
'\n\tBecause I could\n\tNot stop for Death\n\tHe gladly stopped for me\n'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.