Writing text file (achieving extended mode)

Suppose I am writing a text file using the following code.

df <- iris
write.table(df, "data/iris.txt")

When I open the file in Notepad ++ , it displays CRLF.

crlf

If I replace \n with \r, it displays CR. If I do the opposite, it becomes LF. So my question is: How can I achieve CR or LF or CRLF directly from the write.table() ( or any other function)?

See https://npp-user-manual.org/docs/searching/#extended-search-mode to know about \n and \r.

replace

Thanks for the link to the user manual.

Notepad ++ has the EOL conversion option in the Edit menu
so if nothing else works you can change to CRLF, LF or CR.
The eol argument of write.table has the options (on my Windows system)

  • \n (default on Windows) -> CRLF
  • \r -> CR

I did not find an option to get LF on my system

1 Like

@HanOostdijk Many thanks for the suggestions! I find them very helpful.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.