Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
1 view
in R Programming by (7.3k points)
edited by

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

Hello

World

to a file named "output.txt"?

2 Answers

+2 votes
by
edited

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)

close(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 (108k points)

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

fileConn<-file("abc.txt")

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

close(fileConn)

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

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...