在循环内将引号粘贴到字符串中
使用 R,我想生成多个字符串,例如:
"modelCheck("var1_d.bug")"
"modelCheck("var2_d.bug")"
...
"modelCheck("var10_d.bug")"
我通常会使用 for 循环并粘贴(如果我不必担心双引号),如下所示:
for(i in 1:10){
str<-paste("modelCheck(var",i,"_d.bug)",sep="")
print(str)
}
但是,我需要将双引号包含在字符串,因此请求帮助?
Using R, I want to produce multiple character strings such as:
"modelCheck("var1_d.bug")"
"modelCheck("var2_d.bug")"
...
"modelCheck("var10_d.bug")"
I would usually use a for loop and paste (if I did not have to worry about the double quotation marks) as such:
for(i in 1:10){
str<-paste("modelCheck(var",i,"_d.bug)",sep="")
print(str)
}
However, I need to include the double quotation marks within the character string, hence the appeal for help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用反斜杠转义引号:
另一种方法是使用单引号用引号将字符串括起来:
Simply escape the quotation marks with backslashes:
An alternative is to use single quotes to enclose the string: