How can I calculate the slope of multiple subsets of a data frame more efficiently? [duplicate]
问题 This question already has answers here : Linear Regression and group by in R (10 answers) Closed 4 years ago . I have a data set that contains the optical absorption ( a ) across a range of wavelengths ( wl ) for 16 different samples ( bod ) on 5 different days ( day ). The dput output for samples ( bod ) 1 - 3 is below. I need the slope of the natural log of the absorption by wavelength for each sample on each day. My current approach has been to do this manually: # calculate and extract the