"\\" is stored as a single backslash, just as "\n" is a single newline
character. It is printed with an extra backslash.
> nchar("\\")
[1] 1
> cat(paste0("\\", "\n"))
\
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Sat, Dec 6, 2014 at 11:00 AM, Prof J C Nash (U30A)
wrote:
> This i
fname = "John"; lname = "Smith"
ans <- paste( fname, " \\ ", lname )
cat( ans)
print( ans )
Note that ans only has one backslash in it, but print gives you a
source-suitable string with the escape character.
---
Jeff Newmill
Thanks. Now why didn't I think of that? However, it underlines that
there is an implicit call to print(), which processes the string rather
than simply dumping it to the screen. That's something to remember (and
I should have!).
Best, JN
On 14-12-06 02:30 PM, Ben Tupper wrote:
> Hi,
>
> When yo
Hi,
When you call paste without assigning the value it returns to anything it runs
through the print command. So, while your string may contain escapes, using
print will not present escapes as you are expecting them. In this case you
could wrap cat() around your paste command.
> cat(paste(
This is NOT critical. It arose due to a fumble fingers when developing
an R example, but slightly intriguing.
How could one build a string from substrings with a single backslash (\)
as separator. Here's the reproducible example:
fname = "John"; lname = "Smith"
paste(fname, lname)
paste(fname, ln
5 matches
Mail list logo