Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Rows and Columns

A number of operators are available to extract data from matrices. The single open square bracket [ is used to one or more elements from a matrix, while the double open square bracket returns just the specific element specified, requiring all relevant subscripts to be supplied.

> ds[1:20,]		        # Rows 1 to 20.
> ds[,5:10]      		# Columns 5 to 10. 
> ds[,c(3,5,8,9)]		# Columns 3, 5, 8, and 9.
> lst[[1]]                      # First element of list lst.

The [ operator can select multiple elements from an object whilst [[ and $ select just a single element.



Copyright © 2004-2006 [email protected]
Support further development through the purchase of the PDF version of the book.
Brought to you by Togaware.