R Data
R Data
R Core Team
Table of Contents
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1
Imports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.1 Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Export to text files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Spreadsheet-like data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.1
2.2
2.3
2.4
2.5
2.6
Variations on read.table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Fixed-width-format files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Data Interchange Format (DIF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Using scan directly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Re-shaping data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Flat contingency tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Relational databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.1
4.2
Binary files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.1
5.2
Image files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
7.1
7.2
7.3
Types of connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Output to connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Input from connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
7.3.1 Pushback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.4 Listing and manipulating connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.5 Binary connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
7.5.1 Special values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
ii
Network interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
8.1
8.2
Appendix A
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Acknowledgements
The relational databases part of this manual is based in part on an earlier manual by Douglas
Bates and Saikat DebRoy. The principal author of this manual was Brian Ripley.
Many volunteers have contributed to the packages used here. The principal authors of the
packages mentioned are
DBI
David A. James
(https: / /
CRAN
.
R-project .
org
/
package=DBI)
dataframes2xls Guido van Steen
(https: / /
CRAN
.
R-project .
org
/
package=dataframes2xls)
foreign
Thomas Lumley, Saikat DebRoy, Douglas Bates, Duncan
(https: / / Murdoch and Roger Bivand
CRAN
.
R-project .
org
/
package=foreign)
gdata
Gregory R. Warnes
(https: / /
CRAN
.
R-project .
org
/
package=gdata)
ncdf4
David Pierce
(https: / /
CRAN
.
R-project .
org
/
package=ncdf4)
rJava
Simon Urbanek
(https: / /
CRAN
.
R-project .
org
/
package=rJava)
RJDBC
Simon Urbanek
(https: / /
CRAN
.
R-project .
org
/
package=RJDBC)
Acknowledgements
RMySQL
David James and Saikat DebRoy
(https: / /
CRAN
.
R-project .
org
/
package=RMySQL)
RNetCDF
Pavel Michna
(https: / /
CRAN
.
R-project .
org
/
package=RNetCDF)
RODBC
Michael Lapsley and Brian Ripley
(https: / /
CRAN
.
R-project .
org
/
package=RODBC)
ROracle
David A, James
(https: / /
CRAN
.
R-project .
org
/
package=ROracle)
RPostgreSQL Sameer Kumar Prayaga and Tomoaki Nishiyama
(https: / /
CRAN
.
R-project .
org
/
package=RPostgreSQL)
RSPerl
Duncan Temple Lang
RSPython
Duncan Temple Lang
RSQLite
David A, James
(https: / /
CRAN
.
R-project .
org
/
package=RSQLite)
SJava
John Chambers and Duncan Temple Lang
WriteXLS
Marc Schwartz
(https: / /
CRAN
.
R-project .
org
/
package=WriteXLS)
XLConnect
Mirai Solutions GmbH
(https: / /
CRAN
.
R-project .
org
/
package=XLConnect)
XML
Duncan Temple Lang
(https: / /
CRAN
.
R-project .
org
/
package=XML)
Brian Ripley is the author of the support for connections.
1 Introduction
Reading data into a statistical system for analysis and exporting the results to some other system
for report writing can be frustrating tasks that can take far more time than the statistical analysis
itself, even though most readers will find the latter far more appealing.
This manual describes the import and export facilities available either in R itself or via
packages which are available from CRAN or elsewhere.
Unless otherwise stated, everything described in this manual is (at least in principle) available
on all platforms running R.
In general, statistical systems like R are not particularly well suited to manipulations of
large-scale data. Some other systems are better than R at this, and part of the thrust of
this manual is to suggest that rather than duplicating functionality in R we can make another
system do the work! (For example Therneau & Grambsch (2000) commented that they preferred
to do data manipulation in SAS and then use package survival (https://CRAN.R-project.
org/package=survival) in S for the analysis.) Database manipulation systems are often very
suitable for manipulating and extracting data: several packages to interact with DBMSs are
discussed here.
There are packages to allow functionality developed in languages such as Java, perl and
python to be directly integrated with R code, making the use of facilities in these languages even
more appropriate. (See the rJava (https://CRAN.R-project.org/package=rJava) package
from CRAN and the SJava, RSPerl and RSPython packages from the Omegahat project, http://
www.omegahat.net.)
It is also worth remembering that R like S comes from the Unix tradition of small re-usable
tools, and it can be rewarding to use tools such as awk and perl to manipulate data before
import or after export. The case study in Becker, Chambers & Wilks (1988, Chapter 9) is an
example of this, where Unix tools were used to check and manipulate the data before input to
S. The traditional Unix tools are now much more widely available, including for Windows.
This manual was first written in 2000, and the number of scope of R packages has increased
a hundredfold since. For specialist data formats it is worth searching to see if a suitable package
already exists.
1.1 Imports
The easiest form of data to import into R is a simple text file, and this will often be acceptable for
problems of small or medium scale. The primary function to import from a text file is scan, and
this underlies most of the more convenient functions discussed in Chapter 2 [Spreadsheet-like
data], page 8.
However, all statistical consultants are familiar with being presented by a client with a
memory stick (formerly, a floppy disc or CD-R) of data in some proprietary binary format,
for example an Excel spreadsheet or an SPSS file. Often the simplest thing to do is to use
the originating application to export the data as a text file (and statistical consultants will
have copies of the most common applications on their computers for that purpose). However,
this is not always possible, and Chapter 3 [Importing from other statistical systems], page 14,
discusses what facilities are available to access such files directly from R. For Excel spreadsheets,
the available methods are summarized in Chapter 9 [Reading Excel spreadsheets], page 29.
In a few cases, data have been stored in a binary form for compactness and speed of access.
One application of this that we have seen several times is imaging data, which is normally stored
as a stream of bytes as represented in memory, possibly preceded by a header. Such data formats
are discussed in Chapter 5 [Binary files], page 22, and Section 7.5 [Binary connections], page 26.
For much larger databases it is common to handle the data using a database management
system (DBMS). There is once again the option of using the DBMS to extract a plain file, but
Chapter 1: Introduction
for many such DBMSs the extraction operation can be done directly from an R package: See
Chapter 4 [Relational databases], page 16. Importing data via network connections is discussed
in Chapter 8 [Network interfaces], page 28.
1.1.1 Encodings
Unless the file to be imported from is entirely in ASCII, it is usually necessary to know how it
was encoded. For text files, a good way to find out something about its structure is the file
command-line tool (for Windows, included in Rtools). This reports something like
text.Rd: UTF-8 Unicode English text
text2.dat: ISO-8859 English text
text3.dat: Little-endian UTF-16 Unicode English character data,
with CRLF line terminators
intro.dat: UTF-8 Unicode text
intro.dat: UTF-8 Unicode (with BOM) text
Modern Unix-alike systems, including macOS, are likely to produce UTF-8 files. Windows may
produce what it calls Unicode files (UCS-2LE or just possibly UTF-16LE1 ). Otherwise most files
will be in a 8-bit encoding unless from a Chinese/Japanese/Korean locale (which have a wide
range of encodings in common use). It is not possible to automatically detect with certainty
which 8-bit encoding (although guesses may be possible and file may guess as it did in the
example above), so you may simply have to ask the originator for some clues (e.g. Russian on
Windows).
BOMs (Byte Order Marks, https://en.wikipedia.org/wiki/Byte_order_mark) cause
problems for Unicode files. In the Unix world BOMs are rarely used, whereas in the Windows
world they almost always are for UCS-2/UTF-16 files, and often are for UTF-8 files. The file
utility will not even recognize UCS-2 files without a BOM, but many other utilities will refuse
to read files with a BOM and the IANA standards for UTF-16LE and UTF-16BE prohibit it. We
have too often been reduced to looking at the file with the command-line utility od or a hex
editor to work out its encoding.
Note that utf8 is not a valid encoding name (UTF-8 is), and macintosh is the most portable
name for what is sometimes called Mac Roman encoding.
Chapter 1: Introduction
1. Precision
Most of the conversions of real/complex numbers done by these functions is to full precision,
but those by write are governed by the current setting of options(digits). For more
control, use format on a data frame, possibly column-by-column.
2. Header line
R prefers the header line to have no entry for the row names, so the file looks like
Greenmantle
...
dist
2.5
climb
650
time
16.083
Some other systems require a (possibly empty) entry for the row names, which is what
write.table will provide if argument col.names = NA is specified. Excel is one such system.
3. Separator
A common field separator to use in the file is a comma, as that is unlikely to appear in any
of the fields in English-speaking countries. Such files are known as CSV (comma separated
values) files, and wrapper function write.csv provides appropriate defaults. In some locales
the comma is used as the decimal point (set this in write.table by dec = ",") and there
CSV files use the semicolon as the field separator: use write.csv2 for appropriate defaults.
There is an IETF standard for CSV files (which mandates commas and CRLF line endings,
for which use eol = "\r\n"), RFC4180 (see https://tools.ietf.org/html/rfc4180),
but what is more important in practice is that the file is readable by the application it is
targeted at.
Using a semicolon or tab (sep = "\t") are probably the safest options.
4. Missing values
By default missing values are output as NA, but this may be changed by argument na. Note
that NaNs are treated as NA by write.table, but not by cat nor write.
5. Quoting strings
By default strings are quoted (including the row and column names). Argument quote
controls if character and factor variables are quoted: some programs, for example Mondrian
(https://en.wikipedia.org/wiki/Mondrian_(software), do not accept quoted strings.
Some care is needed if the strings contain embedded quotes. Three useful forms are
> df <- data.frame(a = I("a \" quote"))
> write.table(df)
"a"
"1" "a \" quote"
> write.table(df, qmethod = "double")
"a"
"1" "a "" quote"
> write.table(df, quote = FALSE, sep = ",")
a
1,a " quote
The second is the form of escape commonly used by spreadsheets.
6. Encodings
Text files do not contain metadata on their encodings, so for non-ASCII data the file needs
to be targetted to the application intended to read it. All of these functions can write to
a connection which allows an encoding to be specified for the file, and write.table has a
fileEncoding argument to make this easier.
Chapter 1: Introduction
The hard part is to know what file encoding to use. For use on Windows, it is best to use
what Windows calls Unicode2 , that is "UTF-16LE". Using UTF-8 is a good way to make
portable files that will not easily be confused with any other encoding, but even macOS
applications (where UTF-8 is the system encoding) may not recognize them, and Windows
applications are most unlikely to. Apparently Excel:mac 2004/8 expected .csv files in
"macroman" encoding (the encoding used in much earlier versions of Mac OS).
Function write.matrix in package MASS (https://CRAN.R-project.org/package=MASS)
provides a specialized interface for writing matrices, with the option of writing them in blocks
and thereby reducing memory usage.
It is possible to use sink to divert the standard R output to a file, and thereby capture the
output of (possibly implicit) print statements. This is not usually the most efficient route, and
the options(width) setting may need to be increased.
Function write.foreign in package foreign (https: / / CRAN . R-project . org /
package=foreign) uses write.table to produce a text file and also writes a code file that will
read this text file into another statistical package. There is currently support for export to SAS,
SPSS and Stata.
1.3 XML
When reading data from text files, it is the responsibility of the user to know and to specify
the conventions used to create that file, e.g. the comment character, whether a header line
is present, the value separator, the representation for missing values (and so on) described in
Section 1.2 [Export to text files], page 5. A markup language which can be used to describe not
only content but also the structure of the content can make a file self-describing, so that one
need not provide these details to the software reading the data.
The eXtensible Markup Language more commonly known simply as XML can be used to
provide such structure, not only for standard datasets but also more complex data structures.
XML is becoming extremely popular and is emerging as a standard for general data markup and
exchange. It is being used by different communities to describe geographical data such as maps,
graphical displays, mathematics and so on.
XML provides a way to specify the files encoding, e.g.
<?xml version="1.0" encoding="UTF-8"?>
although it does not require it.
The XML (https://CRAN.R-project.org/package=XML) package provides general facilities for reading and writing XML documents within R. Package StatDataML (https://CRAN.
R-project.org/package=StatDataML) on CRAN is one example building on XML (https://
CRAN.R-project.org/package=XML). Another interface to the libxml2 C library is provided by
package xml2 (https://CRAN.R-project.org/package=xml2).
yaml is another system for structuring text data, with emphasis on human-readability: it is
supported by package yaml (https://CRAN.R-project.org/package=yaml).
Even then, Windows applications may expect a Byte Order Mark which the implementation of iconv used
by R may or may not add depending on the platform.
2 Spreadsheet-like data
In Section 1.2 [Export to text files], page 5, we saw a number of variations on the format of a
spreadsheet-like text file, in which the data are presented in a rectangular grid, possibly with
row and column labels. In this section we consider importing such files into R.
5. Missing values
By default the file is assumed to contain the character string NA to represent missing values,
but this can be changed by the argument na.strings, which is a vector of one or more
character representations of missing values.
Empty fields in numeric columns are also regarded as missing values.
In numeric columns, the values NaN, Inf and -Inf are accepted.
6. Unfilled lines
It is quite common for a file exported from a spreadsheet to have all trailing empty fields
(and their separators) omitted. To read such files set fill = TRUE.
7. White space in character fields
If a separator is specified, leading and trailing white space in character fields is regarded as
part of the field. To strip the space, use argument strip.white = TRUE.
8. Blank lines
By default, read.table ignores empty lines.
This can be changed by setting
blank.lines.skip = FALSE, which will only be useful in conjunction with fill = TRUE,
perhaps to use blank rows to indicate missing cases in a regular layout.
9. Classes for the variables
Unless you take any special action, read.table reads all the columns as character vectors
and then tries to select a suitable class for each variable in the data frame. It tries in turn
logical, integer, numeric and complex, moving on if any entry is not missing and cannot
be converted.1 If all of these fail, the variable is converted to a factor.
Arguments colClasses and as.is provide greater control. Specifying as.is = TRUE suppresses conversion of character vectors to factors (only). Using colClasses allows the
desired class to be set for each column in the input: it will be faster and use less memory.
Note that colClasses and as.is are specified per column, not per variable, and so include
the column of row names (if any).
10. Comments
By default, read.table uses # as a comment character, and if this is encountered (except
in quoted strings) the rest of the line is ignored. Lines containing only white space and a
comment are treated as blank lines.
If it is known that there will be no comments in the data file, it is safer (and may be faster)
to use comment.char = "".
11. Escapes
Many OSes have conventions for using backslash as an escape character in text files, but
Windows does not (and uses backslash in path names). It is optional in R whether such
conventions are applied to data files.
Both read.table and scan have a logical argument allowEscapes. This is false by default, and backslashes are then only interpreted as (under circumstances described above)
escaping quotes. If this set to be true, C-style escapes are interpreted, namely the control characters \a, \b, \f, \n, \r, \t, \v and octal and hexadecimal representations like
\040 and \0x2A. Any other escaped character is treated as itself, including backslash. Note
that Unicode escapes such as \uxxxx are never interpreted.
12. Encoding
This can be specified by the fileEncoding argument, for example
fileEncoding = "UCS-2LE"
# Windows Unicode files
1
This is normally fast as looking at the first entry rules out most of the possibilities.
10
fileEncoding = "UTF-8"
If you know (correctly) the files encoding this will almost always work. However, we know
of one exception, UTF-8 files with a BOM. Some people claim that UTF-8 files should never
have a BOM, but some software (apparently including Excel:mac) uses them, and many
Unix-alike OSes do not accept them. So faced with a file which file reports as
intro.dat: UTF-8 Unicode (with BOM) text
it can be read on Windows by
read.table("intro.dat", fileEncoding = "UTF-8")
but on a Unix-alike might need
read.table("intro.dat", fileEncoding = "UTF-8-BOM")
(This would most likely work without specifying an encoding in a UTF-8 locale.)
Convenience functions read.csv and read.delim provide arguments to read.table appropriate for CSV and tab-delimited files exported from spreadsheets in English-speaking locales.
The variations read.csv2 and read.delim2 are appropriate for use in those locales where the
comma is used for the decimal point and (for read.csv2) for spreadsheets which use semicolons
to separate fields.
If the options to read.table are specified incorrectly, the error message will usually be of
the form
Error in scan(file = file, what = what, sep = sep, :
line 1 did not have 5 elements
or
Error in read.table("files.dat", header = TRUE) :
more columns than column names
This may give enough information to find the problem, but the auxiliary function count.fields
can be useful to investigate further.
Efficiency can be important when reading large data grids. It will help to specify
comment.char = "", colClasses as one of the atomic vector types (logical, integer, numeric,
complex, character or perhaps raw) for each column, and to give nrows, the number of rows to
be read (and a mild over-estimate is better than not specifying this at all). See the examples in
later sections.
11
On Windows, spreadsheet programs often store spreadsheet data copied to the clipboard in
this format; read.DIF("clipboard") can read it from there directly. It is slightly more robust
than read.table("clipboard") in handling spreadsheets with empty cells.
0.77s
0.93s
0.85s
2.2s
4.5s
12
13
14
15
3.2 Octave
Octave is a numerical linear algebra system (http: / / www . octave . org), and function
read.octave in package foreign (https://CRAN.R-project.org/package=foreign) can read
in files in Octave text data format created using the Octave command save -ascii, with support for most of the common types of variables, including the standard atomic (real and complex
scalars, matrices, and N -d arrays, strings, ranges, and boolean scalars and matrices) and recursive (structs, cells, and lists) ones.
16
4 Relational databases
4.1 Why use a database?
There are limitations on the types of data that R handles well. Since all data being manipulated
by R are resident in memory, and several copies of the data can be created during execution of
a function, R is not well suited to extremely large data sets. Data objects that are more than
a (few) hundred megabytes in size can cause R to run out of memory, particularly on a 32-bit
operating system.
R does not easily support concurrent access to data. That is, if more than one user is
accessing, and perhaps updating, the same data, the changes made by one user will not be
visible to the others.
R does support persistence of data, in that you can save a data object or an entire worksheet
from one session and restore it at the subsequent session, but the format of the stored data is
specific to R and not easily manipulated by other systems.
Database management systems (DBMSs) and, in particular, relational DBMSs (RDBMSs)
are designed to do all of these things well. Their strengths are
1. To provide fast access to selected parts of large databases.
2. Powerful ways to summarize and cross-tabulate columns in databases.
3. Store data in more organized ways than the rectangular grid model of spreadsheets and R
data frames.
4. Concurrent access from multiple clients running on multiple hosts while enforcing security
constraints on access to the data.
5. Ability to act as a server to a wide range of clients.
The sort of statistical applications for which DBMS might be used are to extract a 10%
sample of the data, to cross-tabulate data to produce a multi-dimensional contingency table,
and to extract data group by group from a database for separate analysis.
Increasingly OSes are themselves making use of DBMSs for these reasons, so it is nowadays
likely that one will be already installed on your (non-Windows) OS. Akonadi (https://en.
wikipedia.org/wiki/Akonadi) is used by KDE4 to store personal information. Several macOS
applications, including Mail and Address Book, use SQLite.
17
All of the packages described later in this chapter provide clients to client/server databases.
The database can reside on the same machine or (more often) remotely. There is an ISO
standard (in fact several: SQL92 is ISO/IEC 9075, also known as ANSI X3.135-1992, and SQL99
is coming into use) for an interface language called SQL (Structured Query Language, sometimes
pronounced sequel: see Bowman et al. 1996 and Kline and Kline 2001) which these DBMSs
support to varying degrees.
18
Kline and Kline (2001) discuss the details of the implementation of SQL in Microsoft SQL
Server 2000, Oracle, MySQL and PostgreSQL.
Real number, with optional precision. Often called real or double or double
precision.
integer
smallint
16-bit integer
character(n)
fixed-length character string. Often called char.
character varying(n)
variable-length character string. Often called varchar. Almost always has a limit
of 255 chars.
boolean
date
calendar date
time
time of day
timestamp
date and time
There are variants on time and timestamp, with timezone. Other types widely implemented
are text and blob, for large blocks of text and binary data, respectively.
The more comprehensive of the R interface packages hide the type conversion issues from the
user.
19
20
5 New Mexico
11.4
6
Michigan
12.1
7
Nevada
12.2
8
Florida
15.4
> dbRemoveTable(con, "arrests")
> dbDisconnect(con)
21
maps names to lowercase). Under Windows, DSNs are set up in the ODBC applet in the Control
Panel (Data Sources (ODBC) in the Administrative Tools section).
> library(RODBC)
## tell it to map names to l/case
> channel <- odbcConnect("testdb", uid="ripley", case="tolower")
## load a data frame into the database
> data(USArrests)
> sqlSave(channel, USArrests, rownames = "state", addPK = TRUE)
> rm(USArrests)
## list the tables in the database
> sqlTables(channel)
TABLE_QUALIFIER TABLE_OWNER TABLE_NAME TABLE_TYPE REMARKS
1
usarrests
TABLE
## list it
> sqlFetch(channel, "USArrests", rownames = "state")
murder assault urbanpop rape
Alabama
13.2
236
58 21.2
Alaska
10.0
263
48 44.5
...
## an SQL query, originally on one line
> sqlQuery(channel, "select state, murder from USArrests
where rape > 30 order by murder")
state murder
1 Colorado
7.9
2 Arizona
8.1
3 California
9.0
4 Alaska
10.0
5 New Mexico
11.4
6 Michigan
12.1
7 Nevada
12.2
8 Florida
15.4
## remove the table
> sqlDrop(channel, "USArrests")
## close the connection
> odbcClose(channel)
As a simple example of using ODBC under Windows with a Excel spreadsheet, we can read
from a spreadsheet by
> library(RODBC)
> channel <- odbcConnectExcel("bdr.xls")
## list the spreadsheets
> sqlTables(channel)
TABLE_CAT TABLE_SCHEM
TABLE_NAME
TABLE_TYPE REMARKS
1 C:\\bdr
NA
Sheet1$ SYSTEM TABLE
NA
2 C:\\bdr
NA
Sheet2$ SYSTEM TABLE
NA
3 C:\\bdr
NA
Sheet3$ SYSTEM TABLE
NA
4 C:\\bdr
NA Sheet1$Print_Area
TABLE
NA
## retrieve the contents of sheet 1, by either of
> sh1 <- sqlFetch(channel, "Sheet1")
> sh1 <- sqlQuery(channel, "select * from [Sheet1$]")
Notice that the specification of the table is different from the name returned by sqlTables:
sqlFetch is able to map the differences.
22
5 Binary files
Binary connections (Chapter 7 [Connections], page 24) are now the preferred way to handle
binary files.
23
6 Image files
A particular class of binary files are those representing images, and a not uncommon request is
to read such a file into R as a matrix.
There are many formats for image files (most with lots of variants), and it may be necessary
to use external conversion software to first convert the image into one of the formats for which
a package currently provides an R reader. A versatile example of such software is ImageMagick
and its fork GraphicsMagick. These provide command-line programs convert and gm convert
to convert images from one format to another: what formats they can input is determined when
they are compiled, and the supported formats can be listed by e.g. convert -list format.
Package pixmap (https://CRAN.R-project.org/package=pixmap) has a function read.pnm
to read portable anymap images in PBM (black/white), PGM (grey) and PPM (RGB colour)
formats. These are also known as netpbm formats.
Packages bmp (https: / / CRAN . R-project . org / package=bmp), jpeg (https: / / CRAN .
R-project.org/package=jpeg) and png (https://CRAN.R-project.org/package=png) read
the formats after which they are named. See also packages biOps (https://CRAN.R-project.
org/package=biOps) and Momocs (https://CRAN.R-project.org/package=Momocs), and
Bioconductor package EBImage.
TIFF is more a meta-format, a wrapper within which a very large variety of image formats
can be embedded. Packages rtiff (https://CRAN.R-project.org/package=rtiff) and tiff
(https://CRAN.R-project.org/package=tiff) can read some of the sub-formats (depending
on the external libtiff software against which they are compiled). There some facilities for
specialized sub-formats, for example in Bioconductor package beadarray.
Raster files are common in the geographical sciences, and package rgdal (https://CRAN.
R-project.org/package=rgdal) provides an interface to GDAL which provides some facilities
of its own to read raster files and links to many others. Which formats it supports is determined
when GDAL is compiled: use gdalDrivers() to see what these are for the build you are using. It
can be useful for uncommon formats such as JPEG 2000 (which is a different format from JPEG,
and not currently supported in the macOS nor Windows binary versions of rgdal (https://
CRAN.R-project.org/package=rgdal)).
24
7 Connections
Connections are used in R in the sense of Chambers (1998) and Ripley (2001), a set of functions
to replace the use of file names by a flexible interface to file-like objects.
function url. For convenience, file will also accept these as the file specification and call url.
Sockets can also be used as connections via function socketConnection on platforms which
support Berkeley-like sockets (most Unix systems, Linux and Windows). Sockets can be written
to or read from, and both client and server sockets can be used.
Chapter 7: Connections
25
Chapter 7: Connections
26
7.3.1 Pushback
C programmers may be familiar with the ungetc function to push back a character onto a text
input stream. R connections have the same idea in a more powerful way, in that an (essentially)
arbitrary number of lines of text can be pushed back onto a connection via a call to pushBack.
Pushbacks operate as a stack, so a read request first uses each line from the most recently
pushbacked text, then those from earlier pushbacks and finally reads from the connection itself.
Once a pushbacked line is read completely, it is cleared. The number of pending lines pushed
back can be found via a call to pushBackLength.
A simple example will show the idea.
> zz <- textConnection(LETTERS)
> readLines(zz, 2)
[1] "A" "B"
> scan(zz, "", 4)
Read 4 items
[1] "C" "D" "E" "F"
> pushBack(c("aa", "bb"), zz)
> scan(zz, "", 4)
Read 4 items
[1] "aa" "bb" "G" "H"
> close(zz)
Pushback is only available for connections opened for input in text mode.
Chapter 7: Connections
27
In each case con is a connection which will be opened if necessary for the duration of the
call, and if a character string is given it is assumed to specify a file name.
It is slightly simpler to describe writing, so we will do that first. object should be an atomic
vector object, that is a vector of mode numeric, integer, logical, character, complex or
raw, without attributes. By default this is written to the file as a stream of bytes exactly as it
is represented in memory.
readBin reads a stream of bytes from the file and interprets them as a vector of mode
given by what. This can be either an object of the appropriate mode (e.g. what=integer())
or a character string describing the mode (one of the five given in the previous paragraph or
"double" or "int"). Argument n specifies the maximum number of vector elements to read
from the connection: if fewer are available a shorter vector will be returned. Argument signed
allows 1-byte and 2-byte integers to be read as signed (the default) or unsigned integers.
The remaining two arguments are used to write or read data for interchange with another
program or another platform. By default binary data is transferred directly from memory to
the connection or vice versa. This will not suffice if the data are to be transferred to a machine
with a different architecture, but between almost all R platforms the only change needed is
that of byte-order. Common PCs (ix86-based and x86_64-based machines), Compaq Alpha
and Vaxen are little-endian, whereas Sun Sparc, mc680x0 series, IBM R6000, SGI and most
others are big-endian. (Network byte-order (as used by XDR, eXternal Data Representation)
is big-endian.) To transfer to or from other programs we may need to do more, for example
to read 16-bit integers or write single-precision real numbers. This can be done using the size
argument, which (usually) allows sizes 1, 2, 4, 8 for integers and logicals, and sizes 4, 8 and
perhaps 12 or 16 for reals. Transferring at different sizes can lose precision, and should not be
attempted for vectors containing NAs.
Character strings are read and written in C format, that is as a string of bytes terminated
by a zero byte. Functions readChar and writeChar provide greater flexibility.
28
8 Network interfaces
Some limited facilities are available to exchange data at a lower level across network connections.
29
30
Appendix A References
R. A. Becker, J. M. Chambers and A. R. Wilks (1988) The New S Language. A Programming
Environment for Data Analysis and Graphics. Wadsworth & Brooks/Cole.
J. Bowman, S. Emberson and M. Darnovsky (1996) The Practical SQL Handbook. Using Structured Query Language. Addison-Wesley.
J. M. Chambers (1998) Programming with Data. A Guide to the S Language. Springer-Verlag.
P. Dubois (2000) MySQL. New Riders.
M. Henning and S. Vinoski (1999) Advanced CORBA Programming with C++. Addison-Wesley.
K. Kline and D. Kline (2001) SQL in a Nutshell. OReilly.
B. Momjian (2000) PostgreSQL: Introduction and Concepts. Addison-Wesley. Also available at
http://momjian.us/main/writings/pgsql/aw_pgsql_book/.
B. D. Ripley (2001) Connections. \R News, 1/1, 167. \https://www.r-project.org/doc/
Rnews/Rnews_2001-1.pdf
T. M. Therneau and P. M. Grambsch (2000) Modeling Survival Data. Extending the Cox Model.
Springer-Verlag.
E. J. Yarger, G. Reese and T. King (1999) MySQL & mSQL. OReilly.
31
.dbf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
.xls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21, 29
.xlsx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
odbcClose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
odbcConnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
odbcConnectDbase. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
odbcConnectExcel . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21, 29
odbcConnectExcel2007 . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
odbcDriverConnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
odbcGetInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
odbcQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
open . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
B
bzfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
C
cat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5,
close. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20,
close.socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
count.fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
24
28
10
D
data.restore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
dataframes2xls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
dbClearResult . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
dbConnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
dbDisconnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
dbDriver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
dbExistsTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
dbGetQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
dbReadTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
dbRemoveTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
dbSendQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
dbWriteTable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
F
fetch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
ftable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
G
gzfile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
P
pipe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
pushBack. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
pushBackLength . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
R
read.csv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10, 29
read.csv2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
read.dbf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
read.delim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10, 29
read.delim2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
read.DIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10, 29
read.dta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
read.epiinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
read.fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
read.ftable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
read.fwf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
read.mtp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
read.octave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
read.socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
read.spss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
read.systat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
read.S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
read.table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8, 25, 29
read.xls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
read.xport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
readBin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
readChar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
readClipboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
readLines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11, 25
readxl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
reshape . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
hdf5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
S
I
isSeekable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
M
make.socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
N
netCDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
scan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4, 11, 25
seek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
showConnections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
sink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7, 25
socketConnection. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
sqlCopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
sqlFetch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
sqlFetchMore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
sqlGetResults . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
sqlQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
sqlSave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
sqlTables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stderr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stdin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
stdout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Sys.localeconv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32
12
24
24
24
10
T
textConnection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
truncate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
W
write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5, 25
write.csv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
write.csv2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
write.dbf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
write.dta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
write.foreign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
write.matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
write.socket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
write.table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5, 25
writeBin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
writeChar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
writeLines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
WriteXLS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
unstack. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
url . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
XLConnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
xlsx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
33
Concept index
A
awk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Octave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
ODBC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16, 20
Open Database Connectivity . . . . . . . . . . . . . . . . . . 16, 20
C
comma separated values . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Compressed files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24, 25, 26
CSV files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 10
P
perl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4,
Pipe connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PostgreSQL database system . . . . . . . . . . . . . . . . . . . . .
Pushback on a connection . . . . . . . . . . . . . . . . . . . . . . . .
10
24
20
26
D
Data Interchange Format (DIF) . . . . . . . . . . . . . . . . . . 10
dBase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Dbase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
DBF files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
DBMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
E
Encodings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5, 6
EpiData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
EpiInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Excel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20, 21
Exporting to a text file . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Q
Quoting strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 8
R
Re-shaping data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Relational databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
File connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Fixed-width-format files . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Flat contingency tables . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
S-PLUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
SAS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24, 28
Spreadsheet-like data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
SPSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
SPSS Data Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
SQL queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Stata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Systat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Terminal connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Text connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
I
Importing from other statistical systems . . . . . . . . . . 14
U
Unix tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
URL connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24, 26
locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Minitab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Missing values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6, 9
MySQL database system . . . . . . . . . . . . . . . . . . . . . . 19, 21
Y
yaml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7