There are number of ways in importing data into R, and several formats are available,
- From Excel to R;
- from SPSS to R; and,
- from Stata to R, and more here.
In this post, we are going to talk about importing common data format that we often encounter, such as Excel and Text data. Most of the data are saved in MS Excel, and the best way to import this is to save this in CSV format, below is the procedure:
- Open your Excel data;
- go to File > Save As or press Ctrl+Shift+S;
- name this with anything you want, say "Data". Then before clicking Save, make sure to change the File Format to Comma Delimited Text and better set the directory to My Documents folder, for Windows.
- when saved, this file will have a name "Data.csv".
header = TRUEtells R that the first row of the data are the labels of every column. If set to
FALSE, means the first row of the data are not the labels, but are considered as data points.