How to write lines to a text file in R?

0 votes

In R programming Language, how do I write lines to a text file?

Hello

World

This text to written in a text file named "abc.txt"?

Apr 16, 2018 in Data Analytics by DataKing99
• 8,130 points
1,690 views

2 answers to this question.

0 votes

It is easy and simple:

fileConn<-file("abc.txt")
writeLines(c("Hello","World"), fileConn)
close(fileConn)
answered Apr 16, 2018 by DeepCoder786
• 1,700 points
Thanks, it works!!
+1 vote
sink("outfile.txt")
cat("hello")
cat("\n")
cat("world")
sink()
answered May 24 by anonymous

Related Questions In Data Analytics

0 votes
1 answer

How to import and clean a text file into dataframe in R?

You can use readLines() or read.table() depending ...READ MORE

answered Jul 16 in Data Analytics by anonymous
22 views
0 votes
1 answer

How to write a custom function which will replace all the missing values in a vector with the mean of values in R?

Consider this vector: a<-c(1,2,3,NA,4,5,NA,NA) Write the function to impute ...READ MORE

answered Jul 4, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
136 views
0 votes
1 answer

How can I import a file in R without giving the destination/file path to the specified file?

You can use the window explorer to ...READ MORE

answered Aug 28, 2018 in Data Analytics by Anmol
• 3,620 points

edited Aug 28, 2018 by Vardhan 45 views
0 votes
2 answers

How to create a table in R without external file?

Tibble also creates a table-like structure. Use below ...READ MORE

answered Sep 3 in Data Analytics by anonymous
• 25,580 points
50 views
0 votes
2 answers

How to sort a data frame by columns in R?

You can use dplyr function arrange() like ...READ MORE

answered Aug 21 in Data Analytics by anonymous
• 25,580 points
118 views
0 votes
1 answer

How to convert a list to data frame in R?

Let's assume your list of lists is ...READ MORE

answered Apr 12, 2018 in Data Analytics by nirvana
• 3,060 points

edited Apr 12, 2018 by nirvana 2,464 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
92 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,700 points
108 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,700 points
75 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,700 points
68 views