Tuesday, May 2, 2023

R Tutorial Playlist - How to read and write simple textual content to a file

 If you want to print some text to a file, you can use function cat for that purpose

cat("text to be printed to the file", "./the file.txt")

For reading back of that content to R session, you can use function read.delim like

content <- read.delim("./the file.txt", header= FALSE)

But keep in mind that read.delim is designed for reading of table data, so in case of some regular text, text is going to be returned in the form of list.


For video tutorial, check the link below.



No comments:

Post a Comment