I was wondering if there is a way to subset one of each rows with a unique sch.id in my data below (e.g., the first row of each sch.id)?
Since there are 160 unique sch.id, I expect 160 rows in the final output.
library(tidyverse)
hsb <- read.csv('https://raw.githubusercontent.com/rnorouzian/e/master/hsb.csv')
data <- hsb %>% group_by(sch.id) %>% mutate(math_ave = mean(math))