forked from itlva/Yr3Example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_02.Rmd
45 lines (38 loc) · 846 Bytes
/
file_02.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
title: "Untitled"
author: "Jo Saul"
date: "14/04/2022"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(faux)
```
```{r}
#simulate our data
set.seed(123456)
simdf1 <- rnorm_multi(n=100,
mu=c(50,75),
sd=c(20,25),
r=0.7,
varnames = c('pre', 'post')) %>%
mutate(group='control')
simdf2 <- rnorm_multi(n=100,
mu=c(50,88),
sd=c(20,15),
r=0.7,
varnames = c('pre', 'post')) %>%
mutate(group='intervention')
simdf <- bind_rows(simdf1, simdf2)
simdf.long <- simdf %>% gather(period, score, pre:post)
```
```{r}
#graph
ggplot(simdf.long, aes(x=period, y=score, colour=group)) +
geom_violin() +
geom_boxplot() +
theme_minimal()
```
Instruction:
1. Make boxplots narrower