[R] Need help plotting
DFP
d|pgnu @end|ng |rom gm@||@com
Thu Sep 22 21:40:33 CEST 2022
I'm trying to do as you suggest, but I'm not understanding what I need
to do. I asked what the line pivot_longer(-time, names_to = "y1") would
do if applied to this df:
> tst
time y1 y2
1 18:55 30 19
2 18:56 30 19
3 18:57 29 19
4 18:58 31 19
5 18:59 28 19
6 19:00 28 19
7 19:01 28 19
8 19:02 28 19
9 19:03 28 19
10 19:04 28 19
11 19:05 29 19
I tried to run these lines and then look at tst, but this is what I get:
> tst %>%
+ mutate(time = paste(Sys.Date(), time),
+ time = as.POSIXct(time)) %>%
+ select(time, y1,y2) %>%
+ # reshape to long format
+ pivot_longer(-time, names_to = "y1")
Error in tst %>% mutate(time = paste(Sys.Date(), time), time =
as.POSIXct(time)) %>% :
could not find function "%>%"
How can I learn what the pivot_longer has done to tst?
Darn it--Now I try to run the whole sequence that Rui suggested--it
worked before--and now I get this:
> tst %>%
+ mutate(time = paste(Sys.Date(), time),
+ time = as.POSIXct(time)) %>%
+ select(time, y1,y2) %>%
+ # reshape to long format
+ pivot_longer(-time, names_to = "y1") %>%
+ # now plot
+ ggplot(aes(time, value, color = y1)) +
+ 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()
Error in tst %>% mutate(time = paste(Sys.Date(), time), time =
as.POSIXct(time)) %>% :
could not find function "%>%"
>
What should I try next?
More information about the R-help
mailing list