Maybe use sQuote
?
sQuote("ABC")
# [1] "'ABC'"
This (like its sibling dQuote
) is frequently used to put quotes around some message or other text that's being printed to the console:
cat("ABC", "
")
# ABC
cat(sQuote("ABC"), "
")
# 'ABC'
Do note (as is documented in ?sQuote
) that, depending on the type of quotes needed for your task, you may need to first reset options("useFancyQuotes")
. To ensure that the function decorates your text with simple upright ASCII quotes, for example, do the following:
options(useFancyQuotes = FALSE)
sQuote("ABC")
# [1] "'ABC'"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…