File content

2017/09/15

Create text file add text and write

# Example of creating text file
file.create("./text_file.txt")
# Add text to file
cat("This is first line", file = "text_file.txt")
# Another line
cat("This is second line", file = "text_file.txt", append = T, sep="\n")
# Read lines from file
rlines <- readLines("./text_file.txt")
# Write all lines back to file (overwrite)
writeLines(rlines ,"text_file.txt")