R ggplot2 plot several time series in a plot

前端 未结 1 1073
青春惊慌失措
青春惊慌失措 2021-02-06 09:33

After succeeding (with your help) in plotting meteo variables in single (one variable) graphs I\'m trying to produce a panel with time series of the different variables in my da

相关标签:
1条回答
  • 2021-02-06 10:01

    the issue is twofold. First of all there's no date object within the melted data.frame, which gives you the error message. Second, your FECHA.H_SOLAR is a factor which would make hard plotting the dates correctely. So here is my solution:

    datos <- source("http://ubuntuone.com/42j1RqUmNmxUuCppW4gElX")[[1]]
    library(reshape2)
    library(ggplot2)
    
    datos$PRECIP[is.na(datos$PRECIP)] <- 0
    dm <- melt(datos,id="FECHA.H_SOLAR")
    # change FECHA.H_SOLAR to POSIXct so you get your dates right
    dm$Fecha <- as.POSIXct(dm$FECHA.H_SOLAR, "%y/%m/%d %H:%M:%S", tz = "")
    qplot(Fecha, value, data = dm, geom = "line", group = variable) +
      facet_grid(variable ~ ., scale = "free_y")
    

    enter image description here

    Hope it Helps

    0 讨论(0)
提交回复
热议问题