I need help because I am unfamiliar with using ggplot2
to plot two time series datasets with different number of rows and different measurements. I found in previous answers regarding how to solve the first problem and I'm pretty sure I can solve also the second one, but I don't know how to solve them together. Here is the code to simulate what I need to do, but in the plot that the code produces I need to solve the problem with the different ranges. How can I set two different y-axes?
x <- rnorm(100)
y <- rnorm(100)
data1 <- data.frame(x,y)
x1 <- rnorm(50)
y1 <-rnorm(50) + 500
data2 <- data.frame(x1,y1)
names(data2)[1]<-paste("x")
names(data2)[2]<-paste("y")
data <- rbind(data1,data2)
data$dataset = c(rep("A", 100), rep("B", 50))
ggplot(data, aes(x = x, y = y, col=dataset)) + geom_line()
Thanks for your attention and excuse me if the question is not clear enough, this is my first question here and I know I have to learn a lot.