Skip to content

quotation marks and scan

7 messages · Rolf Turner, michael.weylandt at gmail.com (R. Michael Weylandt, Erin Hodgess +3 more

#
(1) The backslashes are not really there; they are an artefact of the R 
print() function.
Try cat(u,"\n").  I think this might be an FAQ.

(2) Is not your problem the fact that your are setting "replacement" 
equal to the
thing you are trying to get rid of?  I.e. don't you want

     v <- gsub(pattern='\"',replacement='',x=u)     ???

Either I am misunderstanding your intent or you need another cup of coffee.

     cheers,

     Rolf
On 11/18/13 11:07, Erin Hodgess wrote:
They're not actually there so don't try too hard to rid yourself of them:

x <- "\'"

length(x)
print(x)
cat(x, "\n")

Make sure you're clear on the difference between what's stored by the computer and what it print()s. Rarely the same, though cat() is often slightly more honest.
On Nov 17, 2013, at 17:07, Erin Hodgess <erinm.hodgess at gmail.com> wrote:

            
#
[See in-line below]
On 17-Nov-2013 22:38:30 Rolf Turner wrote:
Is the above line a Fortune?
-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 17-Nov-2013  Time: 23:55:48
This message was sent by XFMail
#
On Sun, 17 Nov 2013, Ted Harding wrote:

            
Why not? ;-) On R-Forge now.
Z
#
I know you have a solution, but I would have suggested using print() with
quote=FALSE as a better way to illuminate what is going on, as in this
example:
[1] "bah\"bah"
[1] "bah\"bah"
[1] bah"bah

As others said, the backslash isn't really there. So you only have to get
rid of the " which you can do with
[1] "bahbah"



To summarize, in R, due to its rules for formatting printed output, what
you see isn't always exactly what you have, and this is an example.