Search code examples
rggplot2neural-networkaesmlp

How do I undo ggplot data error code to plot data?


I keep getting the same error when I enter this code:

ggplot(exchangeGBP) + aes(Date, GBP/EUR) + geom_line(color = "deepskyblue")

the error code: Error in FUN(X[[i]], ...) : object 'Date' not found

should I install a package or change the code?


Solution

  • The + before aes seems to be the issue

    library(ggplot2)
    ggplot(exchangeGBP, aes(Date, `GBP/EUR`)) + 
             geom_line(color = 'deepskyblue') +
             theme_bw()
    

    data

    set.seed(24)
    exchangeGBP <- tibble(Date = seq(Sys.Date() - 10, 
          length.out = 10, by = '1 day'), `GBP/EUR` = rnorm(10))