This is just a incomplete introduction to some common tasks.

Importing data, package foreign
Statistical software

Package foreign has functions to read SPSS, SAS, Stata, Minitab, Systat, EpiInfo, Octave, S files; as well as functions to read and write ARFF (Weka) and DBF files.

The first argument for all functions is the file name, format specific options follow. Refer to the documentation for each of the functions for details, e.g. help(read.spss).

To read for instance an SPSS file, write:

world <- read.spss("c:/world.sav",

By default variables with value labels are converted to R factors (read.spss(file, use.value.labels=FALSE) changes the default; the optional argument generates a data frame.

There is also a spss.get function in package {Hmisc} using read.spss with additional options.

Reading Excel files

Note that these functions only work on 32 bit Windows.

The corresponding functions are found in library xlsReadWrite (Windows only): read.xls will read an Excel file (see help(read.xls) for details. Example:

world1 <- read.xls("c:/world.xls")

On windows (32 and 64) you could use RExcel, an Excel that lets you use R and Excel together. In all other situations you should export an Excel file to CSV or another text format and use the functions described in the next section.

Reading raw (table) data {utils}

read.table() and its predefined variants read.csv (comma delimited), read.csv2 semicolon delimited) and read.delim (tab delimited) read tabular data into a data frame. It has many options to control in detail what is to be read and how to convert it into numerical or non-numerical variables, defining row and column names etc.

Instead of reading form a file, you can also directly read from the clipboad read.table("clipboard",header=T).

Importers in package memisc

The package creates an importer object from SPSS fixed column files (spss.fixed.file), SPSS system (spss.system.filespss.system.file), SPSS portable files (spss.portable.file) and Stata files(). [More flexible than {foreign}; see documentation for more details.

See also

R has quite many facilities to import data from other statistical software, as well as spreadsheets, database files and common formats for data. including access to XML files, and other web based formats like JSON.