How to use Arrange Method In R Language
The arrange method in the dplyr package is an important method to perform the sorting of data based on the values present at least in one column. By default the data is arranged in ascending order according to the column which is specified as the argument to the arranged method. In the following code snippet, the data frame rows are arranged according to the column rating, wherein the rows with the minimum rating are displayed first in the output.
Syntax : arrange(col-name-to-sort-the-data)
R
print ( "Arranging data frame by rating column" ) data_frame %>% arrange (rating) |
Output:
Single-Table Analysis with dplyr using R Language
The dplyr package is used to perform simulations in the data by performing manipulations and transformations. It can be installed into the working space using the following command :
install.packages("dplyr")
Let’s create the main dataframe:
R
#installing the required libraries library (dplyr) #creating a data frame data_frame = data.frame (companies = c ( "Geekster" , "w3wiki" , "Wipro" , "TCS" , "w3wiki" , "w3wiki" , "TCS" , "Wipro" , "Geekster" , "Wipro" ), people = c (100, NA ,532,454,234,554,223,122,432,453), rating = c (4,3,5, NA ,5,3, NA ,4,5,2)) print ( "Original Data frame" ) print (data_frame) |
Output :
Contact Us