Shige
Using the foreign package, R can read and write data in many different formats, including
library(foreign)
auto <- read.dta("http://www.stata-press.com/data/r12/auto.dta")
names(auto)
[1] "make" "price" "mpg" "rep78"
[5] "headroom" "trunk" "weight" "length"
[9] "turn" "displacement" "gear_ratio" "foreign"
We can do the same thing using Stata
Demo using Stata, run “read_data.do”
There are a number of R packages that can read and write Excel files, including:
Here is a nice introduction. Again, it is a bad idea to use Excel for serious data analysis!
Let's take a look at an example.
x08 <- read.csv("2008.csv", na.strings = "NA")
Creates an R data frame called “x08” from the plain text file “2008.csv”.
A simple demo importing a CSV data into Stata
We are going to work on some huge CSV files.
I will use the data for 2004, 2005, 2005, 2006, 2007, and 2008. Combined together, we are dealing with CSV data roughly 3.5 GB in size. The resulted R data frame exceeds 5 GB.
In short, out-of-memory data can be handled in the following ways:
Doing the demo, this could take some time, be warned!
Pros:
Cons: