grouping – What does n=n( ) mean in R?

grouping – What does n=n( ) mean in R?

This is from the dplyr package. n=n() means that a variable named n will be assigned the number of rows (think number of observations) in the summarized data.

the %>% is read as and then and is way of listing your functions sequentially rather then nesting them. So that command is saying you should do the grouping and then summarize the result of the grouping by the number of rows in each group and then ungroup that result, and then group the un-grouped data based on n and then summarize that by the total number of rows in each of the new groups.

grouping – What does n=n( ) mean in R?

Leave a Reply

Your email address will not be published.