• No products in the cart.

103.2.8 Exporting Data

In previous post we saw  An Example of Merge and Join

Writing data in CSV file

Another important feature available in R is the export function. With this function, the data created in R can be saved into any other format like the csv, xlsx, etc. Just as we used the function read.csv() to read the contents of the CSV file into R, there is a function called write.csv(), using which the data compiled can be exported to other formats. The syntax for export is shown below:

>all_customer<-merge(Bills_unique,Complaints_unique,by="cust_id",all=TRUE)
>write.csv(all_customer, "C:\\Users\\venk\\Desktop\\Temp\\all_customer.csv")

It is important to give the correct path before executing, as this may throw an exception.

Writing data in txt file

Data in R can also be saved in the text files. The syntax is shown below

>all_customer<-merge(Bills_unique,Complaints_unique,by=”cust_id”,all=TRUE)
>write.table(all_customer,”C:\\Users\\venk\\Desktop\\Temp\\all_customer.txt”, sep=”\t”)

The above code saves the data from all_customer data in the form of test file into ‘all_customer.txt’, to the path specified in the code.

In this session we discussed data importing from various sources. We learned some basic commands to work with data. We also learned to manipulate the datasets, creating new variables, sorting the data sets, handling duplicates, merging and joining the datasets, etc. There data handling techniques are very important for data analysis.

 

20th June 2017

Statinfer

Statinfer derived from Statistical inference. We provide training in various Data Analytics and Data Science courses and assist candidates in securing placements.

Contact Us

info@statinfer.com

+91- 9676098897

+91- 9494762485

 

Our Social Links

top
© 2020. All Rights Reserved.