I don't understand why this error is appearing. the normal cause is data being read as character strings. What am I missing?
I have two dataframes, individually I can plot them, but I want to plot both on the same graph. The first plots the depth against date_time, a 5 second interval dataset. The second plots a variable 'mixed layer depth' against date, a daily interval dataset.
gg <- ggplot()
gg <- gg + geom_line(data = Mn, aes(x = Date_time, y = 1-Depth, color = Temperature), size = 0)
gg # this works on it's own
gg <- gg + geom_line(data = MLDepth, aes(x = Date, y = 1-ML_Depth, color = "red"))
gg # this works on it's own. but when together with above, causes error.
gg <- gg + theme(legend.title = element_blank(), legend.position = 'none')
gg <- gg + xlab("Date") + ylab("Depth")
gg
When I try to plot them both on the same plot, I get the 'Error: Discrete value supplied to continuous scale'
Both Mn$Date_time and MLDepth$Date are posixct format e.g. "2013-10-14 12:30:00". Depth and ML_Depth are both numeric. There are no NA's.
> str(MLDepth)
'data.frame': 88 obs. of 2 variables:
$ Date : POSIXct, format: "2013-10-14 08:00:00" "2013-10-15 08:00:00" "2013-10-16 08:00:00" "2013-10-17 08:00:00" ...
$ ML_Depth: num 14.1 15.2 16.3 20.9 16.6 ...
> str(Mn)
'data.frame': 1510819 obs. of 5 variables:
$ Date_time : POSIXct, format: "2013-10-14 12:30:00" "2013-10-14 12:30:05" "2013-10-14 12:30:10" "2013-10-14 12:30:15" ...
$ Depth : num 64.4 65.9 65.9 66.4 67.9 ...
$ Temperature: num 27.5 27.5 27.4 27.4 27.2 ...
$ Light_Level: int 148 148 148 148 147 147 146 146 146 146 ...
$ Date : Date, format: "2013-10-14" "2013-10-14" "2013-10-14" "2013-10-14" ...