Reading other file formats – Excel, SAS, and other data sources

R can be used to read (and write) files in various formats other than the native RDS, .RData, and text files. In particular, there are mature R connectors for Excel, SAS, and various other third-party platforms.

The most commonly used package in R for reading files in other formats is foreign. As per its description in CRAN, the library can be used to read files in S, SPSS, Stata, SAS, Weka, and other formats.

The package, SASxport, is commonly used to read and write files in SAS and is quite mature.

There are also various packages for reading Microsoft Excel files such as XLConnect, xlsx, and gdata. Many of them rely on Java in order to process the files and installation may be slightly more complex or error-prone. A more recent package, called readxl, which is part of the tidyverse group of packages, utilizes the libxls library in C and RapidXML in C++ in order to read and write .xls and .xlsx files respectively.

Among the popular text-based formats, the RJSON and jsonlite packages can be used to read JSON.

Miscellaneous database connectors exist in R. Examples include RODBC, ODBC, ROracle, and others. As noted earlier, dbplyr is perhaps the most frequently used connector today due to its ability to apply dplyr code on data stored natively in an external database. It does so by creating a SQL expression equivalent to the R dplyr code.

Finally, it is also possible to store data in the raw binary format using the readBin and writeBin functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.108.150