How to do it...

The steps to use the arrange() verb are very simple and intuitive. The following are the steps:

  1. Import the dataset into the R environment.
  2. Call the arrange() function.
  3. Provide the entire data frame as input.
  4. Specify the variable names.

Here is the actual code to implement the steps:

        arrangeExample <- arrange(USAairlineData2016, ORIGIN, DEST)
  1. If you are interested to do sorting in descending order, then you must use the desc() function within the arrange() verb as follows:
        arrangeExample2 <- arrange(USAairlineData2016, ORIGIN,   
desc(DEST))
  1. The base R alternative code to sort the rows is as follows:
        sortRows <- USAairlineData2016[order(USAairlineData2016$ORIGIN,  
USAairlineData2016$DEST),]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset