R paste function error

痞子三分冷 提交于 2020-01-25 20:25:52

问题


I trying to produce this output character string

CONTAINS(ORIG_DOC,'SECTIONS("7 - Past Medical/Surgical History")(PRECISE FORM OF "DM", PRECISE FORM OF "DM2", "diabetes")') <> 0

using the paste function as below

paste("CONTAINS(ORIG_DOC,'SECTIONS("7 - Past Medical/Surgical History")(PRECISE FORM OF "DM", PRECISE FORM OF "DM2", "diabetes")') <> 0")

I am getting an error

Error: unexpected numeric constant in "paste("CONTAINS(ORIG_DOC,'SECTIONS("7"

Not sure what I am missing here, any help is much appreciated.


回答1:


Escape all double-quotes " as \" and use noquote:

> txt = noquote(paste("CONTAINS(ORIG_DOC,'SECTIONS(\"7 - Past Medical/Surgical History\") (PRECISE FORM OF \"DM\", PRECISE FORM OF \"DM2\", \"diabetes\")') <> 0"))
> txt
[1] CONTAINS(ORIG_DOC,'SECTIONS("7 - Past Medical/Surgical History") (PRECISE FORM OF "DM", PRECISE FORM OF "DM2", "diabetes")') <> 0
>


来源:https://stackoverflow.com/questions/32643848/r-paste-function-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!