Row wise operation in R using Dplyr

Row wise operation in R can be performed using rowwise() function in dplyr package. Dplyr package is provided with rowwise() function with which we will be doing row wise maximum or row wise minimum operations.

We will be using iris data to depict the example of rowwise() function.


mydata2 <-iris 

iris data will be looking like

case when statement in R dplyr 1


We will be creating additional variable row_max using mutate function and rowwise() function to store the row wise maximum variable.

df1 = mydata2 %>%
  rowwise() %>% mutate(row_max= max(Sepal.Length:Petal.Width))


So the snapshot of resultant data frame will be

rowwise function in R dplyr

Row wise operation in R using Dplyr                                                                                                         Row wise operation in R using Dplyr

DataScience Made Simple