0

Ive tried to add dates instead of number of hours on the X-axis on this plot, which represents daily prices at different hours throughout the period of a month.

elspot_prices_2021_hourly_eur <- read_excel("elspot-prices_2021_hourly_eur.xlsx")
elspot_prices_2021_daily_eur <- read_excel("elspot-prices_2021_daily_eur.xlsx")

#Seasonaity of same hour
elspot <- as.double(elspot_prices_2021_hourly_eur$...9[-1]) #DK1 is row 9 
plot((24*(1:31) - 21), elspot[(24*(1:31) - 21)], col="deepskyblue", 
     ylim=c(9, 120), xlab="Hour", ylab="Price in Eur/h", 
     main="Seasonality of hourly prices in January 2021")
lines((24*(1:31) - 21), elspot[(24*(1:31) - 21)], col="deepskyblue")
points((24*(1:31) - 6), elspot[(24*(1:31) - 6)], col="lightcoral")
lines((24*(1:31) - 6), elspot[(24*(1:31) - 6)], col="lightcoral")
legend("topleft", legend=c("3AM", "6AM"), col=6:3, pch=19, bty="n")

The best I could come up with is

date_daily <- as.Date(elspot_prices_2021_daily_eur$`Elspot Prices in EUR/MWh`, 
                      format="%m/%d/%y %H")[-1]
hours <- c("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12",
           "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24")
date_hourly <- paste(hours[(0:8759) %% 24 + 1], date_daily[(0:8759) %/% 24 + 1])
date_hourly <- as_datetime(date_hourly, format="%H %Y-%m-%d")

But without luck

What the plot currently looks like

jay.sf
  • 60,139
  • 8
  • 53
  • 110
  • 2
    You could improve your chances of finding help here by adding a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). Adding a MRE and an example of the desired output (in code form, not tables and pictures) makes it much easier for others to find and test an answer to your question. That way you can help others to help you! P.S. Here is [a good overview on how to ask a good question](https://stackoverflow.com/help/how-to-ask) – dario May 04 '22 at 11:40
  • Have you tried to [`merge`](https://stackoverflow.com/a/1300618/6574038) your two data frames first? Please add the complete outputs of `dput(elspot_prices_2021_hourly_eur[1:10, ])` `dput(elspot_prices_2021_daily_eur[1:10, ])` in an [edit](https://stackoverflow.com/posts/72111510/edit) to your question. – jay.sf May 04 '22 at 12:04

0 Answers0