Hello, I want to plot a subset of my data respecting 2 conditions. I wrote a code in order to do it and it works well but the graph I get is only a part of the data that should be represented. Indeed in my data I have ages from 0 to 110 and when I plot with the condition Age > 90 I only get the data from Age 90 to 100.
This is my code
plot(ex ~ Age, data=subset(female.period.lifetable_1x1, Year == 2020 & Age > 90), type = "l", xlab ="Age", ylab = "E(x)", main = "Espérance de vie périodique des femmes en fonction de l'âge")
lines(x = female.period.lifetable_1x1$ex[female.period.lifetable_1x1$Year == 2015], col = "blue")
lines(x = female.period.lifetable_1x1$ex[female.period.lifetable_1x1$Year == 1955 ], col = "red")
legend(80, 80, legend=c("2020", "2015", "1955"),
col=c("blue", "black","red"), lty = 1:1,
title="Period", text.font=4, bg='lightblue')
This is the graph I get
and this is the graph I need
And when I use the same code but with the condition Age > 100 instead of Age > 90 and I get the graph for all ages like there was no condition.
Could someone tell me what is going wrong?
Thanks in advance