Object-oriented programming refers to the practice of defining a data object which represents something of interest and a set of operations that can be carried out on that object. For example, consider the set of real numbers. Each member of this set can be considered an object upon which common operations can be conducted, such as addition, subtraction, multiplication, etc. In object-oriented programming, the structure of a data object is typically much more complicated. In the present situation, one of the data objects defined represents the (possibly multivariate) data, {z(s1),...,z(sn)}, containing the locations of sampling sites and values observed at those sites. Operations defined on this data structure include the exploratory and modeling functions introduced above.
S+ supports object-oriented programming through the definition of
complex data objects and the definition of functions that act on those
objects. Objects in S+ can be a scalar, a vector, a matrix, a
list or a data frame. A list is simply a collection of, possibly heterogeneous,
objects. Thus, it is possible to have a list that consists of a
vector, a matrix, and another list. A data frame organizes data in
rows and columns. Each column represents a variable and each row
represents a case. This allows objects to be created
that represent very complicated phenomena. For example, the following
S+ statement creates a list containing a numeric vector and a list:
> list.obj <- list(vect=c(1,2,3), + lst=list(chars=c(`a','b','c'),ints=c(1,2,3)))
When conducting object-oriented programming, objects are assigned a
"class" that indicates to functions what type of data the object
contains. For instance, in this framework the data objects that
represent spatial locations and associated observed values are
assigned a class of "point". The class of any S+ object can be
determined with the class()
function.
Operations on objects are implemented as S+ functions, which take
an object of a particular class and conduct an operation upon it. Many
simple S+ functions directly support object orientation. For example,
almost every object will have a related operation that allows the data
in the object to be visualized or plotted. Therefore, the plot routine
in S+ looks at its first argument to see whether it has been assigned
a class. If it has, S+ executes a function named
plot.class
(if this function can be located) instead of
the default plot function. In this way, the operation of plotting any
object is done through the plot
function, with which every S+
user is familiar.
S+ GeoStat | Introduction | OOPLa | Data Structures | Functions | Download |