Some plots cannot be done in ggplot2

Hi everyone I am trying to make a multiple time series plot in R, but it seems that it depends on the data set, in the following plot I show the ideal plot where the line plot are ok as well the period X label, DATA SET 1

The next plot uses the same code but different data [DATA SET 2] as the above and for some reason does not plot the lines and the period values properly

I did the same experiment with the java line plot using a portiion of the same data of the second plot [DATA SET 2] and I had the same problem, as you can see in the following image

The last plot uses the same data of the previous plot [DATA SET 2] or in other words a portion of the data of the second plot and show the line plot properly.

So it seems contradictory that

My purpose is to plot the second plot is a correct way as it resembles more real data than the first plot.

I am attaching the workflow with data

Thanks in advance

Mau

Multiple Time Series.knwf (87.5 KB)

I think the reason is that with the second set of data there is a gap in the numeric values of period and the system tries to bridge that by drawing a straight line. I think if you would handle the period as just label points (what basically happens in the last example) it looks like you would expect it to be.

The system has no idea that 201812 is the end of the year but tries to fill all the numbers up to 201901.

image

3 Likes