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
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 manipulating 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