Exporting Data in R
1. Writing comma-delimited text file (CSV)
2. Writing tab-delimited text file
![]() |
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
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")
Post a Comment