VOOZH about

URL: https://www.geeksforgeeks.org/r-language/how-to-use-write-table-in-r/

⇱ How to Use write.table in R? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Use write.table in R?

Last Updated : 23 Jul, 2025

In this article, we will learn how to use the write.table() in the R Programming Language. The write.table() function is used to export a dataframe or matrix to a file in the R Language. This function converts a dataframe into a text file in the R Language and can be used to write dataframe into a variety of space-separated files for example CSV( comma separated values) files.

Syntax:

write.table( df, file)

where:

  • df: determines the dataframe to be converted.
  • file: determines the file name to write data into with full path.

Example:

Here, we will write a dataframe into a space-separated text file in the R Language by using write.table().

Output:

👁 Image

Write dataframe into manual symbol separated text file:

To write a dataframe into a text file separated by a manual symbol, we use the sep parameter to determine the symbol that separates the data in the text file. In this way, we can write comma-separated-values, tab-separated values, etc.

Syntax:

write.table( df, file, sep)

where:

  • df: determines the dataframe to be converted.
  • file: determines the file name to write data into with full path.
  • sep: determines with a symbol for separation.  Default is a space.

Example:

Here, we will write a dataframe into a comma-separated text file in the R Language by using write.table() function with sep parameter.

Output:

👁 Image
Comment
Article Tags:

Explore