Wednesday, March 5, 2014

How To Import a Data File Into R Statistics Program

Quick and Easy Way to Import Data Files Into R Statistics Program

Before you import data into the R statistical program, save your data file as a .csv (comma separated values). You can do this in Excel or OpenOffice by doing a "save as" and selecting .csv. Don't put spaces in the file name. It also helps to save the file on a jump drive so the file location will be easy to type into the R console.

In my example, I type in the name I want to call the data, the request to read.table, the file location and file name, a command that tells the program to expect a header at the top of the columns. Make this FALSE if you don't have names at the top of your columns. Finally I type out that the data is separated by a comma. Watch the video for the exact command. YouTube doesn't like lines of programming in the video description.

If you do it right, the program will not really respond. If you made an error, the program will tell you. Confirm you've imported the file by typing the name you gave the data and pressing return. You should then see all of the data on the screen.

Interested in financial markets beyond the Dow and S&P? Sign up for a free account at ADVFN and get global market data.