[R] Generating the Ctrl-M character
Jeff Newmiller
jdnewmil at dcn.davis.ca.us
Fri Nov 11 05:55:41 CET 2011
Wow, Deadpan David.
How about using the escape sequence "\r"?
Keep in mind that Ctrl-M is used as the end-of-line character on some operating systems, so accomplishing this may not be portable, and you didn't specify your operating system. On the three main platforms (*nix, Windows/DOS, and Mac), "\r" should work, but "\n" may get munged.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
David Winsemius <dwinsemius at comcast.net> wrote:
>
>On Nov 10, 2011, at 9:35 PM, Ashim Kapoor wrote:
>
>> Dear R-helpers,
>>
>> I want to append a Ctrl-M character to a string and then save it to
>> a text
>> file.
>>
>> mystring<-"This is a test."
>>
>> # How do I add a Ctrl-M to it in the end ??
>>
>> cat(mystring,file="testfile")
>>
>
> > cntrl_m <- intToUtf8(13)
>
> > cat(cntrl_m,file="testfile")
>
>The resulting file seems to have a "blank line" in my editor.
>
>--
>
>David Winsemius, MD
>West Hartford, CT
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list