knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%", fig.retina = 2 ) library(tidyverse) library(patchwork)
The goal of dataforsocialscience
is to bundle a set of data sets that are useful for teaching statistics in a social science field.
You can install the current version of dataforsocialscience from github as follows:
if(!require(remotes)){ install.packages(remotes) } remotes::install_github("statisticsforsocialscience/dataforsocialscience")
These are the datasets contained in this package.
library(tidyverse) library(dataforsocialscience) robo_care %>% names() robo_care %>% ggplot() + aes(cse, y = robo_bed, color = gender) + geom_jitter(width = 0.2, height = 0.2, alpha = 0.8) + geom_smooth(method = "lm") + scale_x_continuous("Computer Self-Efficacy", breaks = 1:6) + scale_y_continuous("Would you accept that a robot brings you to bed?", breaks = 1:6) + labs(color = "Gender")
data("anova_phone") ggplot(anova_phone) + aes(phone, whatsapp, color = phone) + geom_point() + ggtitle("Sum of Squares within") + scale_y_continuous("Whatsapp messages per day", breaks = 1:10) + geom_line(data = data.frame(x = c(0.6,1.4), y = c(2.0,2.0)), aes(x,y), inherit.aes = FALSE, size = 1, color = 2) + geom_label(label = "M1", x = 1.3, y = 2.3, inherit.aes = FALSE, size = 6) + geom_line(data = data.frame(x = c(1.6,2.4), y = c(5.0,5.0)), aes(x, y), inherit.aes = FALSE, size = 1, color = 3) + geom_label(label = "M2", x = 2.3, y = 5.3, inherit.aes = FALSE, size = 6) + geom_line(data = data.frame(x = c(2.6,3.4), y = c(8.0,8.0)), aes(x,y), inherit.aes = FALSE, size = 1, color = 4) + geom_label(label = "M3", x = 3.3, y = 8.3, inherit.aes = FALSE, size = 6)
p1 <- simpson_paradox %>% ggplot() + aes(x = V2, y = V1, color = group) + geom_point() + geom_smooth(method = "lm") p2 <- simpson_paradox %>% ggplot() + aes(x = V2, y = V1) + geom_point() + geom_smooth(method = "lm") p2 + p1 + patchwork::plot_annotation(title = "Demonstrating the Simpson Paradox")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.