I have this function:
plotS<-function(data){
        library(ggplot2)
        p<-ggplot(data,aes(x=date,y=y))+geom_line(aes(y=data[,2],color=colnames(data)[2]))
        p<-p+geom_line(aes(y=data[,3],color=colnames(data)[3]))
        return(p)    
    }
the input, data, is an n by 3 data.frame like this
    date        A       ADI
1   2007-01-03  34.300  32.84
2   2007-01-04  34.410  33.41
3   2007-01-05  34.090  33.03
4   2007-01-08  33.970  33.29
5   2007-01-09  34.010  33.24
...
when I run the function, it always return:
Error in data[, 2] : object of type 'closure' is not subsettable
I think it because in ggplot2, aesthetics can only take column name as parameter. But the problem is the input data set always have different name in column2 and column3. Is there any simple solution?