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")

Spread the Word!
Share
Related Posts
About Author:

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

0 Response to "Exporting Data in R"

Post a Comment

Next → ← Prev

Looks like you are using an ad blocker!

To continue reading you need to turnoff adblocker and refresh the page. We rely on advertising to help fund our site. Please whitelist us if you enjoy our content.