![]() |
VOOZH | about |
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:
👁 ImageTo 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