From the course: Learning the R Tidyverse

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Row-wise groups: rowwise() and c_across()

Row-wise groups: rowwise() and c_across() - R Tutorial

From the course: Learning the R Tidyverse

Row-wise groups: rowwise() and c_across()

- [Instructor] We finished looking at how to do column-wise grouping within your data in a tidyverse. It's time to look at row-wise grouping with row-wise and c_across. Let's see how to use these functions and do row-wise grouping in the project 04_07b. In our row-wise script, let's load the tidyverse on line one and we'll read in our dataset exam_data on line three. Let's print that dataset to the console and take a look at it. So what we have is we have some students and we have the exam scores on various different subjects across different year groups. Now, what if we wanted the average result by row, so for each student within each year, instead of across the columns? Well, we need to start with row wise. So we pipe our data into the function rowwise. And when we run this, scroll to the top of the tibble, we can see that our tibble is now row-wise grouped. We're now going to use mutate to create a new column on the far right-hand side of the dataset. So we'll use mutate and our…

Contents