Exporting Data in R

Exporting Data in R
Exporting Data with R

1. Writing comma-delimited text file (CSV)
write.csv(mydata,"C:/Users/Deepanshu/Desktop/test.csv")

2. Writing tab-delimited text file
write.table(mydata, "C:/Users/Deepanshu/Desktop/test.txt", sep="\t")

3. Writing Excel File

Step 1 : Install the package once
install.packages("xlsReadWrite")

Step 2 : Define path and sheet name in the code below
library(xlsReadWrite)
write.xls(mydata, "c:/mydata.xls")

4. Writing SAS File

Step 1 : Install the package once
install.packages("foreign")
Step 2 : Define path in the code below
library(foreign)
write.foreign(mydata, "c:/mydata.txt", "c:/mydata.sas",   package="SAS")

5. Writing SPSS File

Step 1 : Install the package once
install.packages("foreign")
Step 2 : Define path in the code below
library(foreign)
write.foreign(mydata, "c:/mydata.txt", "c:/mydata.sps",   package="SPSS")

About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 8 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Telecom and Human Resource.

Related Posts:
0 Response to "Exporting Data in R"

Post a Comment

We have Zero Tolerance to Spam. Comments with links will be deleted immediately upon our review.

Next → ← Prev
Love this Post? Spread the Word!
Share