R Package dplyr Function vs T-SQL – Part 2

ByHariharan Rajendran

R Package dplyr Function vs T-SQL – Part 2

Following my previous post, we have another few functions on dplyr package which will be covered in this post.

Arrange Function

As part of data modelling, we need to sort the data to analyze further.

In T-SQL we can easily perform the sort on the data as like below. It uses “Order by” clause to sort the data.

In R, we need to use arrange function.


DF_Arrange<- DF_select %>%

group_by(State) %>%

summarise(Total = sum(Price)) %>%



Mutate Function

The next, very common task is to build the calculated column to satisfy the business logic. This can be easily done with the help of “mutate” function.


DF_mutate <- DF_select %>%

group_by(State) %>%

summarise(Total = sum(Price)) %>%

mutate(“10%of Total” = Total/10) %>%



About the Author

Hariharan Rajendran author

Hariharan Rajendran is a MVP in Data Platform and Microsoft Certified Trainer with 10+ years of experience in Database, BI and Azure platforms. Hariharan is also an active community leader, speaker & organizer and leads the Microsoft PUG (Power BI User Group – Chennai), SQLPASS Power BI Local Group – Chennai and an active speaker in SQL Server Chennai User Group and also a leader in Data Awareness Program worldwide events. Hariharan also frequently blogs (www.dataap.org/blog), provides virtual training (on ad-hoc basis) on Microsoft Azure, Database Administration, Power BI and database development to worldwide clients/audience.

Comments Are Closed!!!