Hello everyone,
I have a problem with plotting my data in ggplot
The data is a data frame with three columns: date, value, variable
The data is already in posixct format, the value as numeric.
$ date : POSIXct, format: "2020-06-09 11:30:00" "2020-06-09 11:40:00" "2020-06-09 11:50:00" "2020-06-09 12:00:00" ...
$ variable: Factor w/ 93 levels "AMSTE01_04","AMSTE01_06",..:
$ value : num 17 17.1 17.2 17.2 17.2 ...
I would like to make a ggplot (geom_line). The problem is when I try script1 that I get an empty graph, and with script2 I get an error
script1 <- ggplot(mydata, aes("date", "value", color = "variable"))+
geom_line()
# here the result is an empty grid
script2 <- ggplot(mydata, aes("date", "value", color = "variable"))+
geom_line() +
scale_x_datetime(date_labels = "&Y-%m-%d %H:%M:%S")
# >Error: Invalid input: time_trans works with objects of class POSIXct only
I feel like ggplot is not able to read the data, but I dont know how to fix it.
Thanks in advance!