May 2022
Beginner to intermediate
656 pages
18h 50m
English
In chapter 2, we review a wide range of methods for importing data into R. But sometimes, you’ll want to go the other way—exporting data from R—so data can be archived or imported into external applications. In this appendix, you’ll learn how to output an R object to a delimited text file, an Excel spreadsheet, or a statistical application (such as SPSS, SAS, or Stata).
You can use the write.table() function to output an R object to a delimited text file. The format is
write.table(X, outfile, sep=delimiter, quote=TRUE, na="NA")
where x is the object and outfile is the target file. For example, the statement
write.table(mydata, "mydata.txt", sep=",")
saves the dataset mydata to a comma-delimited ...
Read now
Unlock full access