10
INPUT/OUTPUT
One of the most underemphasized topics
in many university programming courses
is input/output (I/O). I/O plays a central
role in most real-world applications of comput-
ers. Just consider an ATM cash machine, which uses
multiple I/O operations for both input—reading your
card and reading your typed-in cash request—and
output—printing instructions on the screen, printing
your receipt, and most important, controlling the
machine to output your money!
R is not the tool you would choose for running an ATM, but it features
a highly versatile array of I/O capabilities, as you will learn in this chapter.
We’ll start with the basics of access to the keyboard and monitor, and then
go into considerable detail on reading and writing files, including the nav-
igation of file directories. Finally, we discuss R’s facilities for accessing the
Internet.