问题
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