在 R 中嵌套两种以上的引号

Nesting more than two types of quotes in R

我想知道如何在 R 的同一行中容纳两种以上的引号。假设我想打印:

'first-quote-type1 "first-quote-type2 "second-quote-type2 'sencond-quote-type1

在开头和结尾使用一个引号,我们有:

print("'first-quote-type1 "first-quote-type2 "second-quote-type2 'sencond-quote-type1")

Error: unexpected symbol in "print("'first-quote-type1 "first"

在这种情况下,我尝试按照 Python 的要求包含三重引号:

print(''''first-quote-type1 "first-quote-type2 "second-quote-type2 'sencond-quote-type1''')

print("""'first-quote-type1 "first-quote-type2 "second-quote-type2 'sencond-quote-type1""")

但是,我也遇到了类似的错误。关于如何使此语法在 R 中工作的一些想法?

要在引号中使用引号,您可以使用反斜杠转义引号字符

print("the man said \"hello\"")

但是,R 中的打印函数总是会转义字符。 要不显示转义字符,请使用 cat() 而不是

所以...

cat("the man said \"hello\"") 将 return the man said "hello"