Reputation: 1365
i found it is difficult to create character : " is entered as \ "
when i input in R:
" is entered as \"
+
" is entered as \ "
[1] " is entered as "
>" is entered as \\ "
[1] " is entered as \ "
>" is entered as \\"
[1] " is entered as \"
how can i get character " is entered as \ "?
i am still confused
cat("is entered as \" )
is entered as >
> "is entered as \\"
[1] "is entered as \"
> print ("is entered as \\")
[1] "is entered as \"
Upvotes: 1
Views: 157
Reputation: 60070
Is this what you were trying to achieve?:
> x <- "START \" is entered as \\\" END"
> cat(x)
Gives:
START " is entered as \" END
You have to escape both the double quote "
, and the backslash \
, in order to have them display normally.
To clear up any confusion between whether the double quotes printed in the output are part of the string, or just symbols that wrap around the string, I've added START
at the start of the string and END
at the end.
Upvotes: 2
Reputation: 66842
"hoge \\"
is actually hoge \
print
shows \
as \\
, so you find \\
for \
.
try cat
:
> cat("is entered as \\" )
is entered as \
and probably nchar
will manifest this:
> nchar("\\" )
[1] 1
Upvotes: 3