Hi i have a problem that occurs in R.
I can't handle the y - axis, which is hour : minute format.
here is the code sample.
library("data.table")
library("ggplot2") #load library
time <- c("00:05", "06:57","19:00","23:10","00:32","15:00","01:30","03:20") #time data
class <- c("Math", "Eng", "History","Math", "Eng", "History","Math", "Eng") #Course data
day <- c("1/21","1/21","1/21","1/21","1/22","1/22","1/23","1/23") #day data
df <- data.frame(time, class, day) #dataframe
df$time = as.POSIXct(df$time, format = "%H:%M") #make char to time format
pic <- ggplot(df, aes(x = class, y=df$time)) +
scale_y_datetime(date_breaks = "1 hour") +
facet_grid(. ~ day) #draw picture, break time in 1 hour
pic
if i draw this graph, then Y axis have the year, month and day. i tried to erase the format of year, month and day through as.POSIXct, but didnt work.
also, the limit of time is not from 00:00 to 24:00, its from 1/20 23:00 to 1/22 00:00
i don't know how to figure out the solution of it.