I have a data frame as follows.
TIME PRICE
2013-01-01 23:55:03 446.6167
2013-01-01 23:55:02 441.0114
2013-01-01 23:54:59 446.7600
I want to plot the following as a scatter plot in R using ggplot. The times are unique.
I want to plot the data showing x labels only once in every 30 minutes. Can someone help me?
class(inter_1$TRANSACTION_TIME)
[1] "factor"
Thanks in advance!
You need to convert your "TIME" column to a "time" format, since now it is a factor. Something like this would work:
library(anytime)
library(dplyr)
mydf %>%
mutate(TIME = anytime(TIME)) %>%
as_tibble()
## # A tibble: 2 x 2
## TIME PRICE
## <dttm> <dbl>
## 1 2013-01-01 22:55:03 446.6167
## 2 2013-01-01 22:55:02 441.0114
You see that now "TIME" is a "date-time" variable. Then, you can adjust the x-axis using scale_x_date_time
.
HTH.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.