73  ggstatsplot Package

73.1 Violin & Boxplot

Code
dataF %>% 
    select(hb1, fpreg) %>% 
    mutate(hb1 = round(hb1, 1)) %>% 
    na.omit() %>% 
    ggbetweenstats(
      y=hb1, x=fpreg, 
      ggtheme = theme_light(),
      bf.prior = F, 
      xlab = "First Pregnancy",
      ylab = "Hemoglobin",
      title = "Relationship between first pregnancy and hemoglobin",
      outlier.tagging = T,
      outlier.color = "red",
      outlier.shape = 18)
Error in integrate(meta.t.like, lower = (lower - mean.delta)/scale.delta,  : 
  non-finite function value

73.2 Scatter with marginal histogram

Code
dataF %>% 
    ggscatterstats(
        x = mcv1, 
        y = mcv2, 
        ggtheme = theme_light())
Registered S3 method overwritten by 'ggside':
  method from   
  +.gg   ggplot2
`stat_xsidebin()` using `bins = 30`. Pick better value with `binwidth`.
`stat_ysidebin()` using `bins = 30`. Pick better value with `binwidth`.

73.3 Barplot

Code
dataF %>% 
    ggbarstats(
        y = educ, x = fpreg, 
        ggtheme = theme_light(),
        legend.title = "First \nPregnancy",
        xlab = "Educational Level",
        bf.message = F,
        title = "Relationship between educational level and first pregnancy")

73.4 Histogram

Code
dataF %>% 
  gghistostats(
    x = hb1,
    ggtheme = theme_classic(), 
    normal.curve = T, 
    binwidth = 1,
    normal.curve.args = list(size = 1, col = "red"),
    bin.args = list(color = "black", fill = "blue", alpha = 0.1),
    xlab = "Hemoglobin", 
    title = "Distribution of First Hemoglobins")

73.5 Coefficients plot

Code
lm(hb1 ~ hb2 + hb3 + hb4 + hb5, data=dataF) %>% 
    ggcoefstats(output = "plot",
                exclude.intercept = T, 
                ggtheme = theme_light(), 
                color = "red") +
    labs(y = "Covariates", 
         x = "Estimates", 
         title = "Distribution of coefficient estimates (95% CI)")

73.6 Correlation plot

Code
dataF %>% 
    select(hb1, hb1, hb3, hb4, hb5, mcv1, mcv2, mcv3, mcv4, mcv5) %>% 
    ggcorrmat(colors = c("red","white","blue"), 
              ggtheme = theme_bw(),
              matrix.type = "lower")