I am having issues with trying to plot some Time Series data; namely, trying to plot the date (increments in months) against a real number (which represents price).
I can plot the data with just plot(months, mydata)
with no issue, but its in a scatter plot format.
However, when I try the same with ts.plot
i.e. tsplot(months, mydata)
, I get the following error:
Error in .cbind.ts(list(...), .makeNamesTs(...), dframe = dframe, union = TRUE) : no time series supplied
I tried to bypass this by doing tsplot(ts(months, mydata))
, but with this I get a straight linear line (which I know isn't correct).
I have made sure that both months
and mydata
have the same length
EDIT: What I mean by custom x-axis
I need the data to be in monthly increments (specifically from 03/1998 to 02/2018) - so I ran the following in R:
d <- seq(as.Date("1998-03-01"), as.Date("2018-02-01"), "day")
months <- seq(min(d), max(d), "month")
Now that I have attained the monthly increments, I need the above variable, months
, to act as the x-axis for the Time Series plot (perhaps more accurately, the time index).