3
4

2 回答 2

2

Using substr, one sees that the backslashes seem just to be an artefact of printing:

substr(my.string,2,2)

gives

[1] "\""

also, the string length is as you want it:

> nchar(my.string)
[1] 3

if you want to print your string without the backslashes, use noquote :

> noquote(my.string)
[1] a""
于 2013-03-16T06:35:39.807 回答
2

The backslashes is an artifact of the print method. In fact the default print surrounds your string with quotes. You can disable this by setting argument quote to FALSE.

For example You can use :

print(my.string,quote=FALSE)
[1] a""

But I would use cat or write like this :

 cat(my.string)
a""
 write(my.string,"")
a""
于 2013-03-16T07:59:12.957 回答