Exporting Data in R


R Data Science: R Programming A-Z: R For Data Science With Real Exercises!

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

Coursera Data Science

R Tutorials : 75 Free R Tutorials

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

0 Response to "Exporting Data in R"

Post a Comment

Next → ← Prev