O'Reilly logo

Machine Learning with R Cookbook by Chiu Yu-Wei

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required