I know the title makes this sound very easy, but I have a For loop that graphs my data. As the values vary, so too does the limits of the X-axis (different start and end for each plot). However, I want to have a defined X-axis range that stays the same for all similar plots. This is complicated by the fact that there are ~40 possible ranges for the X that I want.
I have a data frame of the x-lims I would like to choose from, for each plot. It basically looks like:
Trait start end
A 123456 134567
B 234546 245678
C 234546 245678
D 345678 356789
and so on. So, if one loop gives me the values: Trait C, start = 235000 and end = 240000, I would like to automatically use the third set of default X-lims.
edit: added more info (Trait).
If your displayed data.frame is called
df(and your are sure your variableendwill be greater thanstart), this should work:Revised to answer revised question
As you add more conditions, you can extend the logic above: