1

My data looks like this:

df <- structure(list(`Recorded ID` = c(6L, 7L, 9L, 11L, 12L, 13L, 14L, 
16L, 17L, 18L), Initial = c(2L, 0L, 0L, 2L, 22L, 4L, 0L, 9L, 
16L, 20L), Final = c(2L, 2L, 2L, 0L, 19L, 0L, 0L, 4L, 4L, 20L
)), class = "data.frame", row.names = c(NA, -10L))

I am trying to make a plot that is similar to this

EXCEPT only change would be is that City on that plot would be "Record ID" from my data. I am having a lot of trouble if someone could help me thank you so much!

I have tried many things but none have helped

1

1 Answer 1

1

This is a bar plot which can be accomplished using geom_bar:

df %>%
  pivot_longer(-`Recorded ID`, names_to = 'Key')%>%
  mutate(Recorded.ID = factor(`Recorded ID`))%>%
  ggplot(aes(y = Recorded.ID, x = value, fill = Key) ) + 
  geom_bar(stat = 'identity', position = 'dodge')

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

If you use geom_col() you can skip the stat = "identity" argument
@JohanRosa yes, thats right. Though for newbies, its not straightforward to connect geom_col to barplots
You're right, good point of view.
Thank you all so much!! Yes I am a newbie so I am slowly learning things I really appreciate all your help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.