Hi Payal,
These are the ways to write text files from R.
var - R Variable.
1. Comma delimited text file - use write_csv(var,"path/filename.csv")
write_csv(m,"path/file.csv")
2. CSV to Excel file - use write_excel_csv(var,"path/filename.csv")
write_excel_csv(p,"path/file.csv")
3. Text files with tab - use write_fwf(var,"path/filename.fwf") or write_tsv()
write_fwf(k,"path/file.fwf")
write_tsv(k,"path/file.tsv")
4. line to file - use write_lines(var,"path/filename.csv")
write_lines(c,"path/file.csv")
5. Full text file - use write_file(var,"path/filename.csv")
write_file(b,"path/file.txt")
6. Any delimited file - use write_delim(var,"path/filename.csv")
write_delim(a,"path/file.txt")
hope it helps!