How to perform group-wise linear regression for a data frame in R

Thank you very very much this worked.