I have a data with 8 variables (x1,y1,x2,y2,x3,y3,x4,y4), and i should do a function that generate a 4 plots x1vsy1, x2vsy2, x3vsy3 and x4vsy4.
So i was trying to do that one by one, doing a new data with the variables and after generate de plot.
minidata<-select(alldata,x1,y1)
ggplot(minidata,aes(x1,y1))+geom_point()+ggtitle("m VS n")
This works, but when i try to put that in the function
graph<-function(m,n){
minidata<-select(alldata,m,n)
ggplot(minidata,aes(x=m,y=n))+geom_point()+ggtitle("m VS n")
}
graph(y1,x1)
This doesnt work say "Error in FUN(X[[i]], ...) : object 'y1' not found" what i could do to generate a function that creates the 4 plots?