Writing to Files in R Programming
R programming Language is one of the very powerful languages specially used for data analytics in various fields. Analysis of data means reading and writing data from various files like excel, CSV, text files, etc. Today we will be dealing with various ways of writing data to different types of files using R programming.
R – Writing to Files
Writing Data to CSV files in R Programming Language
CSV stands for Comma Separated Values. These files are used to handle a large amount of statistical data. Following is the syntax to write to a CSV file:
csv() and csv2() are the function in R programming.
- write.csv() uses “.” for the decimal point and a comma (“, ”) for the separator.
- write.csv2() uses a comma (“, ”) for the decimal point and a semicolon (“;”) for the separator.
Writing Data to text files
Text files are commonly used in almost every application in our day-to-day life as a step for the “Paperless World”. Well, writing to .txt files is very similar to that of the CSV files. Following is the syntax to write to a text file:
Writing Data to Excel files
To write data to excel we need to install the package known as “xlsx package”, it is basically a java based solution for reading, writing, and committing changes to excel files. It can be installed as follows:
and can be loaded and General syntax of using it is:
Please Login to comment...