I have these two data:
1.table_range
"code";"sp";"min";"max"
"EI12";"EI";2015-06-01;2015-08-01
"EI21";"EI";2015-01-01;2018-11-01
"EI25";"EI";2019-03-01;2019-03-01
"EI26";"EI";2019-03-01;2020-02-01
"EI27";"EI";2019-10-01;2019-11-01
"EI30";"EI";2016-01-01;2018-05-01
"EI35";"EI";2017-09-01;2017-12-01
"EI38";"EI";2017-02-01;2019-11-01
"EI43";"EI";2018-08-01;2019-01-01
"EI44";"EI";2018-04-01;2018-04-01
"EI45";"EI";2018-09-01;2020-01-01
"EI7";"EI";2014-05-01;2016-04-01
"EI9";"EI";2012-12-01;2015-03-01
2.table_sum
"mes_ano";"code";"sp";"count"
2012-12-01;"EI9";"EI";"1"
2014-05-01;"EI7";"EI";"1"
2015-01-01;"EI21";"EI";"1"
2015-03-01;"EI9";"EI";"1"
2015-06-01;"EI12";"EI";"1"
2015-08-01;"EI12";"EI";"1"
2016-01-01;"EI30";"EI";"2"
2016-04-01;"EI7";"EI";"1"
2016-09-01;"EI21";"EI";"1"
2016-09-01;"EI30";"EI";"1"
2017-01-01;"EI30";"EI";"2"
2017-02-01;"EI38";"EI";"1"
2017-09-01;"EI35";"EI";"1"
2017-10-01;"EI21";"EI";"1"
2017-11-01;"EI21";"EI";"1"
2017-12-01;"EI35";"EI";"1"
2018-02-01;"EI21";"EI";"1"
2018-04-01;"EI21";"EI";"1"
2018-04-01;"EI30";"EI";"1"
2018-04-01;"EI44";"EI";"2"
2018-05-01;"EI21";"EI";"1"
2018-05-01;"EI30";"EI";"1"
2018-07-01;"EI21";"EI";"1"
2018-08-01;"EI43";"EI";"3"
2018-09-01;"EI43";"EI";"1"
2018-09-01;"EI45";"EI";"1"
2018-10-01;"EI21";"EI";"1"
2018-11-01;"EI21";"EI";"1"
2018-11-01;"EI43";"EI";"1"
2019-01-01;"EI43";"EI";"3"
2019-03-01;"EI25";"EI";"2"
2019-03-01;"EI26";"EI";"1"
2019-05-01;"EI38";"EI";"1"
2019-07-01;"EI26";"EI";"1"
2019-08-01;"EI26";"EI";"1"
2019-10-01;"EI27";"EI";"1"
2019-11-01;"EI26";"EI";"1"
2019-11-01;"EI27";"EI";"1"
2019-11-01;"EI38";"EI";"1"
2019-12-01;"EI45";"EI";"1"
2020-01-01;"EI45";"EI";"2"
2020-02-01;"EI26";"EI";"1"
and this graph
lin_temp <- ggplot(data = table_sum, aes(x = mes_ano, y = code)) +
geom_segment(data = table_range, size = 1.2, alpha= 0.8,
aes(x = min, xend = max, y = code, yend = code))+
geom_point(aes(shape = , color=count), size=2)
when I make the graph, the lines are mixed and not in sequence, like this https://i.ibb.co/LgQY838/1.png
I used this How do you specifically order ggplot2 x axis instead of alphabetical order? to get sorted y axis manually like this https://i.ibb.co/DfLSwMJ/2.png
There is a faster way to do sort by date since I have more than 100 codes?