Skip to content

Instantly share code, notes, and snippets.

@naomispence
Created April 25, 2017 15:31
Show Gist options
  • Save naomispence/b25f04865dcd49671d7159c782a0b574 to your computer and use it in GitHub Desktop.
Save naomispence/b25f04865dcd49671d7159c782a0b574 to your computer and use it in GitHub Desktop.
```{r}
#Look at the mean of an interval variable
mean(GSS$childs, na.rm=TRUE)
# This is a generalized linear model of an interval variable with just an intercept, no independent variable
results<-glm(GSS$childs~1, data=GSS)
summary(results)
# This is a generalized linear model of an interval variable with an intercept and an independent variable
results<-glm(GSS$childs~age, data=GSS)
summary(results)
#The line below gives us a scatterplot with a "best fitting line" through it. SEE IF YOU CAN ADD TITLE AND LABELS.
ggplot(GSS, aes(age, childs)) + geom_point() + stat_smooth(method="lm")
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment