0

I am try to get this outcome: enter image description here

This is my df:

 df<- structure(list(Date = structure(c(18319, 18320, 18321, 18322, 18323, 18324, 18325, 18326, 18327, 18328, 18329, 18330, 18331, 18332, 18333, 18334, 18335, 18336, 18337, 18338, 18339, 18340, 18341, 18342, 18343), class = "Date"), Daily_Cases = c(250, 238, 240, 566, 342, 466, 587, 769, 778, 1247, 1492, 1797, 977, 2313, 2651, 2547, 3497, 3590, 3233, 3526, 4207, 5322, 5986, 6557, 5560 ), Tests = c(2427, 3681, 2966, 2466, 2218, 2511, 3981, 2525, 3997, 5703, 7875, 3889, 6935, 12393, 12857, 11477, 11682, 15729, 13063, 10695, 16884, 17236, 24109, 26336, 25180), Proportion = c(10.3, 6.5, 8.1, 23, 15.4, 18.6, 14.7, 30.5, 19.5, 21.9, 18.9, 46.2, 14.1, 18.7, 20.6, 22.2, 29.9, 22.8, 24.7, 33, 24.9, 30.9, 24.8, 24.9, 22.1)), class = "data.frame", row.names = c(NA, -25L)) 

Proportion is the black line, Tests the grey bars and Daily_Cases the red bars. I tried any of the codes only (applied to my cases) but I don't manage to do it.

Can anyone help?

1 Answer 1

3

You don't really help us helping you - what you want to achieve requires a lot of things that need to be implemented. Please focus on one problem per question.

Here to make the graph.

Problems:

library(tidyverse) mydf <- structure(list(Date = structure(c(18319, 18320, 18321, 18322, 18323, 18324, 18325, 18326, 18327, 18328, 18329, 18330, 18331, 18332, 18333, 18334, 18335, 18336, 18337, 18338, 18339, 18340, 18341, 18342, 18343), class = "Date"), Daily_Cases = c(250, 238, 240, 566, 342, 466, 587, 769, 778, 1247, 1492, 1797, 977, 2313, 2651, 2547, 3497, 3590, 3233, 3526, 4207, 5322, 5986, 6557, 5560 ), Tests = c(2427, 3681, 2966, 2466, 2218, 2511, 3981, 2525, 3997, 5703, 7875, 3889, 6935, 12393, 12857, 11477, 11682, 15729, 13063, 10695, 16884, 17236, 24109, 26336, 25180), Proportion = c(10.3, 6.5, 8.1, 23, 15.4, 18.6, 14.7, 30.5, 19.5, 21.9, 18.9, 46.2, 14.1, 18.7, 20.6, 22.2, 29.9, 22.8, 24.7, 33, 24.9, 30.9, 24.8, 24.9, 22.1)), class = "data.frame", row.names = c(NA, -25L)) mydf_long <- mydf %>% pivot_longer(names_to = 'key', values_to = 'value', Tests:Daily_Cases) ggplot(mydf_long) + geom_col(aes(Date, value, fill = key), position = position_dodge()) + geom_line(aes(Date, Proportion *1000, group = 1)) 

Created on 2020-03-23 by the reprex package (v0.3.0)

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

1 Comment

Great stuff! Thanks so much! Sorry I wasn't precise enough. I understood a lot now from your solution. Thanks again

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.