[R] quotation marks and scan

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Nov 18 00:24:36 CET 2013


On Sun, Nov 17, 2013 at 10:42 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> <michael.weylandt at gmail.com> 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")

 Did you mean to do 'nchar(x)' to show that \" was one character?
'length' gives the number of elements in a vector, which in this case
is also one.

 > x=c("\"", '\'')
 > length(x)
 [1] 2
 > nchar(x)
 [1] 1 1



More information about the R-help mailing list