0

Very new to R, but I'm trying to get two simple x,y (date, value) graphs. The sets of values I'm trying to graph are subsets of a larger set of similar values. The graph is essentially representing the entire set instead of the subsets on the x-axis. Here's what I have:

mydata <- read.csv("~/Downloads/AUESA.csv") # columns: DATE, AUESA


aft <- mydata[as.Date(mydata$DATE) > as.Date('2016-11-01'), ]

bef <- mydata[as.Date(mydata$DATE) < as.Date('2016-11-01') & as.Date(mydata$DATE) >= as.Date('2015-05-01'), ]

par(mfrow=c(1,2)) 

plot(x = aft$DATE, y = aft$AUESA, type = 'l')

plot(x = bef$DATE, y = bef$AUESA, type = 'l')

As you can see, the x-axis limits are off enter image description here

I've tried:

plot(x = aft$DATE, y = aft$AUESA, type = 'l', xlim = as.Date(c('2016-11-01', '2018-05-01')))

plot(x = bef$DATE, y = bef$AUESA, type = 'l', xlim = as.Date(c('2015-05-01', '2016-11-01')))

But it just graphs an empty graph with the correct x-axis limits.

Any comments or suggestions are helpful. Thanks.

tjebo
  • 21,977
  • 7
  • 58
  • 94
  • 1
    Welcome to SO. In order to help you, a minimal, complete, verifiable example is helpful, and required. [See here what this is](https://stackoverflow.com/help/mcve). You will find [here some tips how to ask a good question](https://stackoverflow.com/help/how-to-ask)and [here how to make some good example data](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – tjebo Sep 10 '18 at 20:42
  • I'm not quite sure I'm understanding your problem. What is the actual x-range of your data? What are you trying to achieve? – iago-lito Sep 10 '18 at 22:01
  • I need the x-range of my data to be (2016-11-01, 2018-05-01) for one graph and (2015-05-01, 2016-11-01) for the other. I realize these are dates. The graph is currently giving me (1993-01-01, 2018-05-01) for both as the x-axis range. – Micah Wallingford Sep 10 '18 at 23:13

0 Answers0