I have using following function and code to plot a graph:
myfn2 = function(ddf, i, j, k){
p = ggplot()+
geom_point(aes(x=ddf[,i],y=ddf[,j], shape=ddf[,k], color=ddf[,k]))+
labs(x=names(ddf)[i], y=names(ddf)[j])
print(p)
}
myfn2(iris, 1,2,5)
However, the graph is not correct:
The correct graph should be:
How can this be corrected? Also how can title of legend be corrected? Thanks for your help.