Using R to manipulate data

This recipe will discuss how to use the built-in R functions to manipulate data. As data manipulation is the most time consuming part of most analysis procedures, you should gain knowledge of how to apply these functions on data.

Getting ready

Ensure you have completed the previous recipes by installing R on your operating system.

How to do it...

Perform the following steps to manipulate the data with R.

Subset the data using the bracelet notation:

  1. Load the dataset iris into the R session:
    > data(iris)
    
  2. To select values, you may use a bracket notation that designates the indices of the dataset. The first index is for the rows and the second for the columns:
    > iris[1,"Sepal.Length"]
    [1] 5.1
    
  3. You can also select multiple columns ...

Get Machine Learning with R Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.