Book Image

R Object-oriented Programming

By : Black
Book Image

R Object-oriented Programming

By: Black

Overview of this book

This book is designed for people with some experience in basic programming practices. It is also assumed that they have some basic experience using R and are familiar using the command line in an R environment. Our primary goal is to raise a beginner to a more advanced level to make him/her more comfortable creating programs and extending R to solve common problems.
Table of Contents (14 chapters)
4
4. Calculating Probabilities and Random Numbers
12
A. Package Management
13
Index

Network options

Another way to read information is through a network connection using sockets. The methods available to manipulate sockets will be briefly explored in this section. We first explore the high level socket commands that make use of the socketConnection command to create a connector. Next, some of the more basic options are briefly stated. This is an advanced topic beyond the scope of this book, but it is provided here as a matter of completeness.

Opening a socket

The socketConnection command will create a network connection to a given host using a port number. The command returns a connector that can be treated the same as a file connector. In the following example, a connection is opened to the waterdata.usgs.gov website using the standard HTTP port, 80. It then sends the HTTP header necessary to request the data for the daily flow rates for the South Colton station on the Raquette River in northern New York:

> usgs <- socketConnection(host = "waterdata.usgs.gov...