+3 votes
1 view
in R Programming by (6.5k points)
edited by

In the R scripting language, how do I write lines of text, e.g. the following two lines



to a file named "output.txt"?

2 Answers

+2 votes
by (25.3k points)
edited by

You can use the writeLines() function in R to write lines of text to a file as follows:

fileout <-file("output.txt")

writeLines(c("Hello","World"), fileout)


The output.txt file will be stored in your current working directory. 

If you want to explore more in R programming then watch this R programming tutorial for beginner:

+2 votes
by (92.8k points)

It is easy and simple to perform, refer to the following statements:


writeLines(c("Hello","World"), fileConn)


Welcome to Intellipaat Community. Get your technical queries answered by top developers !