What about this:
aaa<-merge(x,y, all=FALSE)
ggplot(aaa,aes(x=x,y=y))+geom_point() ?
Question
I have multiple time series objects covering different periods of time, with gaps in the data, and with varying frequencies (some hourly data, some 15-minute, some 1-minute).
I'm trying to plot different time series objects against one another in x-y scatterplots - to see if there are obvious correlations, and make 'pretty' plots with ggplot for presentation. Obviously, one can only plot/compare data where it exists for x
and y
at the same time.
I'm able to get a quick graphic with base graphics, but would like something more presentable.
for example, this works in base R:
require(zoo)
x <- zoo(sort(rnorm(10)),as.POSIXct("2013/07/26")+1:10)
y <- zoo(sort(rnorm(30)),as.POSIXct("2013/07/26")+(1:30)/2)
plot(x,y)
and trying to do the same with ggplot fails:
data <- rbind(melt(fortify(x),id="Index"),melt(fortify(y),id="Index"))
ggplot(data,aes(x=x,y=y))+geom_point()
Don't know how to automatically pick scale for object of type zoo. Defaulting to continuous
Don't know how to automatically pick scale for object of type zoo. Defaulting to continuous
Error: Aesthetics must either be length one, or the same length as the dataProblems:x
suggestions on better titles/description are welcome
Solution
What about this:
aaa<-merge(x,y, all=FALSE)
ggplot(aaa,aes(x=x,y=y))+geom_point() ?