Hi @Emmadadil. You cannot directly pass the column names x, y, a, b, X, Y of data frame to plot. You have to pass the whole data.frame into it.
library(sf)
#> Linking to GEOS 3.7.2, GDAL 2.3.2, PROJ 6.2.0
set.seed(100)
X=7.5
Y=7.5
f = function(){
a = runif(10,1,10)
return( a=as.integer(a))
}
onlineloc=data.frame(x=f(),y=f())
instore=data.frame(a=f(),b=f())
store=data.frame(X,Y)
plot(onlineloc,main="Online and instore customer loc",col=" red")
points(instore,pch=2)
points(store,pch=15)
legend(x=3.5,y=5,legend=c("Instore Customer","Online Customer","Store"),pch=c(2,1,15),col=c("black","red","black"))

Created on 2019-10-20 by the reprex package (v0.3.0)
Or pass the column values of data frame into it.
library(sf)
#> Linking to GEOS 3.7.2, GDAL 2.3.2, PROJ 6.2.0
set.seed(100)
X=7.5
Y=7.5
f = function(){
a = runif(10,1,10)
return( a=as.integer(a))
}
onlineloc=data.frame(x=f(),y=f())
instore=data.frame(a=f(),b=f())
store=data.frame(X,Y)
plot(onlineloc$x, onlineloc$y,main="Online and instore customer loc",col=" red")
points(instore$a, instore$b,pch=2)
points(store$X, store$Y,pch=15)
legend(x=3.5,y=5,legend=c("Instore Customer","Online Customer","Store"),pch=c(2,1,15),col=c("black","red","black"))

Created on 2019-10-20 by the reprex package (v0.3.0)