library(tidyverse)
library(openintro)
library(stats)
ggplot(data = hfi, aes(x = pf_identity_sex, y = pf_score)) +
  geom_point() +
  stat_smooth(method = "lm", se = FALSE)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 80 rows containing non-finite values (stat_smooth).
## Warning: Removed 80 rows containing missing values (geom_point).

m4 <- lm(pf_score ~ pf_identity_sex, data = hfi)
mypar <- par(mfrow = c(2, 2), oma = c(0, 0, 1.1, 0),
            mar = c(4.1, 4.1, 2.1, 1.1))
plot(m4)

par(mypar)
summary(m4)
## 
## Call:
## lm(formula = pf_score ~ pf_identity_sex, data = hfi)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.5522 -0.7698  0.0153  0.9410  2.4601 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     5.718774   0.061535   92.94   <2e-16 ***
## pf_identity_sex 0.202367   0.007352   27.52   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.105 on 1376 degrees of freedom
##   (80 observations deleted due to missingness)
## Multiple R-squared:  0.3551, Adjusted R-squared:  0.3546 
## F-statistic: 757.6 on 1 and 1376 DF,  p-value: < 2.2e-16