DATA MINING
Desktop Survival Guide by Graham Williams |
|||||
The basic types of objects in R include logical,
integer, double, complex, and
character. We obtain the type of an object using the
typeof function:
> typeof(TRUE) [1] "logical" > typeof(5+4) [1] "double" > typeof(letters) [1] "character" > typeof(typeof) [1] "closure" |
The mode of an object is another indication of the type
of the object. For example, objects of type integer and
double are of mode numeric.
> mode(x) > storage.mode(x) > class(x) # The object class for method dispatch |
Normally we build up an object to have some structure, like a vector, an array, a matrix, or a data frame. The basic building block of a data structure in R is a vector of objects of some type. Indeed, an object of type double will in fact be a vector of numbers.
R will keep track of objects you have created:
> ls() # List all objects you have created. > rm(list=ls(all=TRUE)) # Remove all of your objects. |
In the following sections we introduce each of the main types of objects and illustrate typical operations for manipulating the objects.
Copyright © 2004-2006 Graham.Williams@togaware.com Support further development through the purchase of the PDF version of the book.