[R] Plotting two time series in one graph

Baki UNAL b@k|un@| @end|ng |rom y@hoo@com
Sun May 2 20:38:18 CEST 2021


Hi

I'm trying to plot two time series in one graph. I tried the following code:


p = ggplot() + 
  geom_line(data = dovrez, aes(x = Date, y = Res), color = "blue") +
  geom_line(data = rqa_df_USD, aes(x = DATE, y = LAM), color = "red") +
  xlab('Dates') +
  ylab('Values')
print(p)

But I got the following error:

Hata: `mapped_discrete` objects can only be created from numeric vectors
Run `rlang::last_error()` to see where the error occurred.

Time indexes of my dataframes (dovrez, rqa_df_USD) are not same. First dataframe (dovrez) has 820 date points. Second dataframe (rqa_df_USD) has 75 date points.

How can I plot these two data in one graph?

Best Regards
Baki Ünal



More information about the R-help mailing list