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')
Hello.
Thanks for providing code , but you could take further steps to make it more convenient for other forum users to help you.
Share some representative data that will enable your code to run and show the problematic behaviour.
You might use tools such as the library datapasta, or the base function dput() to share a portion of data in code form, i.e. that can be copied from forum and pasted to R session.
I tried the functions you cited but I don't understand how to use it. However by asking me this I was then checking my data to describe it and I understood my problem. The Age column is a charachter column and not a numeric one.
Glad your problem was solved, I often too fix my faults in the course of attempting to make an issue reproducible, its a nice brain hack in a sense.
Down the road, if you want to offer advice as to how the reprex guide might be improved, I'd be all ears as it's our go to FAQ that almost all first timers to the boards will be asked to read at some point.