Plotting mean and standard error of mean from linear regression

Is this the sort of thing you are looking for?

library(dplyr)
library(ggplot2)
#invent some data
DF <- data.frame(emotion_pred = sample(c(0,1), size = 40, replace = TRUE),
                 emotion_target = sample(c(0,1), size = 40, replace = TRUE),
                 predic_acc = runif(40))
head(DF)

#>   emotion_pred emotion_target predic_acc
#> 1            0              1  0.3906500
#> 2            0              1  0.5477801
#> 3            0              0  0.1167041
#> 4            1              1  0.7130423
#> 5            1              0  0.3001842
#> 6            0              1  0.3866334

#Calculate and plot some statistics
DF_stats <- DF |> group_by(emotion_pred,emotion_target) |> 
  summarize(Avg = mean(predic_acc), N = n())
#> `summarise()` has grouped output by 'emotion_pred'. You can override using the
#> `.groups` argument.
DF_stats
#> # A tibble: 4 × 4
#> # Groups:   emotion_pred [2]
#>   emotion_pred emotion_target   Avg     N
#>          <dbl>          <dbl> <dbl> <int>
#> 1            0              0 0.511     9
#> 2            0              1 0.475    11
#> 3            1              0 0.408     7
#> 4            1              1 0.507    13
ggplot(DF_stats,aes(x = factor(emotion_pred), y = Avg, shape = factor(emotion_target))) +
  geom_point()

Created on 2022-09-06 with reprex v2.0.2

1 Like