Hi,
Let's imagine that Nicol, Steve, Mary are chatting on a Whatsapp private group in 2020. In 2021, Frank joins the group.
I would like to visualise the number of messages each one has written each year.
Here is the code:
year <- factor(c(rep(c(2020), 11), rep(c(2021), 8)))
author <- c("Mary", "Nicol", "Steve", "Mary", "Nicol", "Mary", "Mary", "Mary", "Steve", "Nicol", "Mary",
"Nicol", "Steve", "Frank", "Mary", "Mary", "Frank", "Nicol", "Nicol")
msg <- rep("blablabla", 19)
df <- data.frame(year, author, msg)
p <- ggplot(df, aes(x = author, group = year, fill = year))
p + geom_bar(position = "dodge2")
labs(x = "", y = "Number of messages", title = "Number of messages by year and by author")
The result is shown here:
There is a problem with Frank: I would like to find a simple way to reduce the width of Frank's bar, so that 2020 remains as = 0.
Thanks,
Cheers