[R] Need help plotting

DFP d|pgnu @end|ng |rom gm@||@com
Thu Sep 22 00:35:17 CEST 2022


As I said, the lines below that you provided worked well for me. Can you 
explain what this line does?:

# reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%

-------------------------------------------------

library(ggplot2)
library(dplyr)
library(tidyr)

b %>%
    mutate(Dtime = paste(Sys.Date(), Dtime),
                  Dtime = as.POSIXct(Dtime)) %>%
    select(Dtime, DNO2, MNO2) %>%
    # reshape to long format
    pivot_longer(-Dtime, names_to = "NO2") %>%
    # now plot
    ggplot(aes(Dtime, value, color = NO2)) +
    geom_line() +
    geom_point() +
    scale_color_manual(values = c("orange", "skyblue")) +
    # make datetime labels
    scale_x_datetime(date_breaks = "1 mins", date_labels = "%H:%M") +
    theme_bw()


	[[alternative HTML version deleted]]



More information about the R-help mailing list