Skip to content
Back to formatted view

Raw Message

Message-ID: <79e78d1d-aafe-8aad-7f6e-fdff31a0d125@sapo.pt>
Date: 2021-05-02T19:45:12Z
From: Rui Barradas
Subject: Plotting two time series in one graph
In-Reply-To: <1481832980.304712.1619980698034@mail.yahoo.com>

Hello,

Can you post sample data? For instance, the output of

dput(head(dovrez, 20))
dput(head(rqa_df_USD, 20))


Or maybe you could rbind the data.frames with one column telling which 
of Res or LAM the values come from.


Hope this helps,

Rui Barradas

?s 19:38 de 02/05/21, Baki UNAL via R-help escreveu:
> 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
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>