Help with linear model

I think you are confusing summarise() with mutate() function, to help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

EDIT: I think this example with built-in data is very close to what you are trying to do

library(dplyr)
library(magrittr)

iris %>%
  mutate(aDOT = Sepal.Length / Sepal.Width,
         yac_per_rec = Petal.Length / Petal.Width) %$%
  lm(aDOT ~ yac_per_rec) %>% 
  summary()
#> 
#> Call:
#> lm(formula = aDOT ~ yac_per_rec)
#> 
#> Residuals:
#>      Min       1Q   Median       3Q      Max 
#> -0.71340 -0.17850 -0.00652  0.15870  0.87885 
#> 
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)  2.37802    0.05201  45.722   <2e-16 ***
#> yac_per_rec -0.09844    0.01046  -9.414   <2e-16 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 0.3178 on 148 degrees of freedom
#> Multiple R-squared:  0.3745, Adjusted R-squared:  0.3703 
#> F-statistic: 88.62 on 1 and 148 DF,  p-value: < 2.2e-16
1 Like