addCarriageReturn: Add Carriage Return

Description Usage Arguments Value Note Author(s) Examples

Description

Unix based systems use only the line feed (LF, "\n") character for line breaks whereas Windows both line feed and carriage return (CR, "\r"). This function adds the carriage return in order for files to be read properly on windows.

Usage

1
addCarriageReturn(file.in, file.out = file.in)

Arguments

file.in

The path and name of the input file. A character of length 1.

file.out

The path and name of the output file. A character of length 1. Default is to overwrite.

Value

Nothing is returned. Creates (or overwrites if file.out is not given) a file with added carriage returns.

Note

Useful on Unix systems to make Windows readable .txt and other plain-text files.

Author(s)

Anders Ellern Bilgrau <anders.ellern.bilgrau (at) gmail.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
tmp.dir <- tempdir()
file.in <- file.path(tmp.dir, "NewFile.txt")
file.out <- file.path(tmp.dir, "NewFileForWindows.txt")

# Write the file
cat("This is some text on.\n Hello, newline.", file = file.in)

# Add carriage return if on a unix system
addCarriageReturn(file.in, file.out)

# If on unix, run to see files:
#system(paste("open", file.in))
#system(paste("open", file.out))

AEBilgrau/Bmisc documentation built on May 5, 2019, 11:28 a.m.