The kind of data that you want to import in to R may come in formats of various sorts like those of statistical software, flat files, web data and databases.
In R, it is often found that the various data types require varied approaches. Through this post we list how the more common file types may be imported into R programming.
Typically flat files may said to be simply text files containing table data. R has through its standard distribution the ability to import such a file in to the R environment through the aid of functions like read.table() as well as read.csv() from the package referred to as utils. Also, you may import files like these through readr which is a package famed for its ease of use and swiftness.
If you want to import excel files in to R, one need to carefully examine the readxl package. As an alternative you may also use the gdata package which includes in its functionality importing Excel data and also the XLConnect package. The XLConnect package is more of a real bridge between R and Excel. This basically means that any action that might be done with Excel might very well be done from R.
Other packages of software like SPSS, SAS and STATA are used to produce their own formats of file. This is best handled with the Haven package created by Hadley Wickham. Besides its ability to import such files it is also characterized by its ease of use. As an alternative there is packages like foreign which has the ability to import more esoteric formats like Weka and Systat. It comes with the added functionality to export data to a large number of formats as well.
The database type that you wish to connect to determines the package which is to be used to import from and connect to a relational database. MySQL databases may be connected to through the means of the RMySQL package. Other examples are RpostgreSQL and ROracle. Then you must make use of another R package like DBI in order to manipulate and access the required database.
One may also harvest web data using the R Programming language. This may be done by connecting online resources to R through the use of API or scrape with the help of packages like rvest.
Related posts :