I have a decent looking graph ,which I plotted using
r <- ggplot(data=data2.Gurgaon,aes(x=createdDate,y=count))+geom_point()
Now i want to higlight few points on the graph say 500,1000,5000 etc.. so ,I am trying to write a function , in which i can pass point I want to mark Below is the function I have written
graphPoint <- function(graph,point) {
g <- graph
g <- g+geom_point(aes(x=createdDate[point],y=count[point]),pch=1,size=8,col='black')
g <- g+ geom_point(aes(x=createdDate[point],y=count[point]),pch=16,size=5,col='red')
g
}
when i am passing parameters
r -> graphPoint(r,500)
this is giving error
Error in lapply(X = x, FUN = "[", ..., drop = drop) :
object 'point' not found
i am not that great with R . Hope its possible , But I am missing at some small point .. Thanks.