R |变量在空白空间中生成“\”会混淆gsubfn

时间:2017-12-01 16:32:40

标签: r variables gsub

当我运行我的变量时,它会在空格中生成“\”。

有没有办法删除“\”或维护变量文本的原始格式?

topheader<-'<div id="editor1" class="shinytinymce shiny-bound-input" 
style="resize: none; width: 100%; height: 100%; border-style: none; 
background: gainsboro;">'

print(topheader) 

[1] "<div id=\"editor1\" class=\"shinytinymce shiny-bound-input\" 
style=\"resize: none; width: 100%; height: 100%; border-style: none; 
background: gainsboro;\">"

1 个答案:

答案 0 :(得分:1)

字符串\"代表单个双引号字符。 R以这种方式打印它,因为它将所有字符串打印为双引号,因此它需要转义内部双引号。

如果要将字符值视为实际书写字符,请使用cat

cat(topheader)
# <div id="editor1" class="shinytinymce shiny-bound-input" 
# style="resize: none; width: 100%; height: 100%; border-style: none; 
# background: gainsboro;">
相关问题