[R] Pesky file encoding problem
Jim Lemon
drjimlemon at gmail.com
Mon Nov 7 01:41:41 CET 2016
Hi Joshua,
Use Notepad++. It will also convert the linefeed EOLs to CR/LF.
Jim
On Mon, Nov 7, 2016 at 4:25 AM, Joshua Banta <jbanta at uttyler.edu> wrote:
> Dear everyone,
>
> Please consider the following code, which I am using to make a custom text file. (I need to build the text file line-by-line like this for some idiosyncratic reasons that I will not get into here. But basically the real text file I am making is longer and more complicated than this.)
>
> outfile = "output.arp"
> cat('Title="data"', file=outfile, append=FALSE, sep = "\r\n")
> cat('DataType=DNA', file=outfile, append=TRUE, sep = "\r\n")
> cat('GenotypicData=1', file=outfile, append=TRUE, sep = "\r\n")
> cat('GameticPhase=0', file=outfile, append=TRUE, sep = "\r\n")
> cat('LocusSeparator=WHITESPACE', file=outfile, append=TRUE, sep = "\r\n")
> cat("", file=outfile, append=TRUE, sep = "\r\n")
> cat("[Data]", file=outfile, append=TRUE, sep = "\r\n")
> cat("[[Samples]]", file=outfile, append=TRUE, sep = “")
>
> Here is my question:
>
> When the output file (output.arp) is opened using TextEdit on a Mac, each line is shown separated by one or more carriage returns, which is what I want. When the output file is opened using Notepad on a PC, each line of text runs into the next with no carriage returns, which is not what I want.
>
> How can I make this text file, or convert it, in such a way that it will open on Notepad on a PC showing each line separated by one or more carriage returns?
>
> I am aware of solutions to this problem using other software as an intermediary, such as TextWrangler, but I would like to accomplish this entirely using r itself.
>
> I would be most appreciative of the full code needed to get the job done.
>
> Thanks very much in advance!
> -----------------------------------
> Josh Banta, Ph.D
> Assistant Professor
> Department of Biology and the Center for Environment, Biodiversity and Conservation
> The University of Texas at Tyler
> Tyler, TX 75799
> http://plantevolutionaryecology.org
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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