Reputation: 21
I'm trying to plot two variables from a time series. In order to see correlations between the variables, I've differentiated them and lagged the independent variable. However, when I create a scatter plot I see the data points order and lines between them. How do I change them to dots?
Be_ts <- ts(data=Beasain_full, start=c(2014, 01), end = c(2020, 12), frequency = 12)
log_Be_ts <- log(Be_ts)
plot(lag(diff(log_Be_ts[,'TOTpre']),1),diff(log_Be_ts[,'Unsorted']))
Upvotes: 0
Views: 1018
Reputation: 5813
One approach is to use plot.default
:
Be_ts <- ts(matrix(runif(100), ncol=2), frequency = 12)
log_Be_ts <- log(Be_ts)
plot.default(lag(diff(log_Be_ts[,1]),1),diff(log_Be_ts[,2]))
... another way is to convert the time series object back to a plain vector or matrix with unclass
:
log_Be_ts <- unclass(log_Be_ts)
plot(lag(diff(log_Be_ts[,1]),1),diff(log_Be_ts[,2]))
Note also that I used random numbers to make the example reproducible.
Upvotes: 2