Wednesday, January 16, 2013

How To Extract Subsets of R Objects

There are number of operations that can be used to extract subsets of R objects.

[  --> an object of same class
[[ --> elements of a list or a data frame
$ --> elements of a list or data frame by name

Here are some examples which show you how to use these operations:

1. Extract elements from vector


2. Extract elements from matrices 


3. Extract elements from list


4. Extract multi-elements



5. Extract specific elements



6. Extract elements from partial name



7. Remove missing values




8. Extract data with conditions


Have fun!