Reputation: 149
I've spent an astonishing 4 hours googling and finding not-quite the same answers to do something that should take me 30 seconds.
Here's my data:
DFj <- read.table(text="Intervention Timepoint Proportion
0 baseline .35
0 final .24
1 baseline .25
1 final .43", header=TRUE)
I want a bar plot of 4 bars. There should be two categories, i.e. "baseline" and "final" time points. Baseline should have two bars, control (red) and intervention (blue) which are side by side. Then I want a bit of distance before we have the same two bars with the same colors but with the "final" data. This should be insanely easy but absolutely nothing I google can help me. Any ideas?
Upvotes: 0
Views: 186
Reputation: 86
Is this what you are looking for?
library(tidyverse)
DFj <- read.table(text="Intervention Timepoint Proportion
0 baseline .35
0 final .24
1 baseline .25
1 final .43", header=TRUE)
DFj %>%
ggplot(aes(Timepoint, Proportion, fill = Intervention %>% as.factor())) +
geom_col(position = 'dodge') +
scale_fill_manual(values = c('red', 'blue'))
Upvotes: 1