0

I'm a newbie to R. I have two stations (1 and 2). Each station has two variables (a and b). I want to plot the change in these variables over time using ggplot.

I tried this code to plot the data (You can get the data from this link https://goo.gl/t6fvAJ)

data1 <- read.csv("Stations1.csv", sep=",", header=T)
names(data1)
data1$Date<-as.Date(data1$X, format="%d/%m/%Y")
library(ggplot2)
ggplot(data1, aes(x=Date, y=Y, group=Var)) +   
geom_line() + theme_bw() + facet_wrap(~station, ncol=4, scales="free_y") + xlab("Date")+ylab("")

I couldn't see the changes in variable "b" because it has different scale than variable "a"

I need to add a secondary Y axis to ggplot2 so I can show the changes in variable "b" over time.

Is there any way to do this in ggplot2?

user1237585
  • 63
  • 1
  • 6
  • 1
    http://stackoverflow.com/questions/3099219/plot-with-2-y-axes-one-y-axis-on-the-left-and-another-y-axis-on-the-right, http://stackoverflow.com/questions/21981416/dual-y-axis-in-ggplot2-for-multiple-panel-figure. –  Oct 22 '15 at 00:36
  • another link.. http://stackoverflow.com/questions/18989001/how-can-i-put-a-transformed-scale-on-the-right-side-of-a-ggplot2 – user20650 Oct 22 '15 at 00:56
  • 1
    how about adding another facetting variable , so use either `facet_wrap(Var~station, ncol=2, scale="free_y")` or `facet_grid(Var~station, scale="free_y")` – user20650 Oct 22 '15 at 00:57

0 Answers0