while comparing lat long of two locations it comparing only observation to observation not the complete data frame as in example it gives 2 common lat and longs however there are more than 2 please guide.
Lat= function(){
a = runif(10,29.00,34.00)
a= round(a)
return(a)
}
Long= function(){
b = runif(10,69.00,72.00)
b= round(b)
return(b)
}
onlineloc=data.frame(LAT=Lat(),LONG=Long())
onlineloc
#> LAT LONG
#> 1 33 70
#> 2 34 71
#> 3 30 70
#> 4 32 72
#> 5 30 72
#> 6 34 70
#> 7 31 71
#> 8 29 71
#> 9 31 71
#> 10 30 70
instore=data.frame(LAT=Lat(),LONG=Long())
instore
#> LAT LONG
#> 1 33 71
#> 2 32 70
#> 3 33 71
#> 4 33 71
#> 5 30 70
#> 6 34 72
#> 7 33 70
#> 8 31 71
#> 9 31 71
#> 10 30 70
#set.seed(100)
Z= onlineloc == instore
Z
#> LAT LONG
#> [1,] TRUE FALSE
#> [2,] FALSE FALSE
#> [3,] FALSE FALSE
#> [4,] FALSE FALSE
#> [5,] TRUE FALSE
#> [6,] TRUE FALSE
#> [7,] FALSE FALSE
#> [8,] FALSE TRUE
#> [9,] TRUE TRUE
#> [10,] TRUE TRUE
p=print(instore[Z[,1] & Z[,2], ])
#> LAT LONG
#> 9 31 71
#> 10 30 70
nrow(p)
#> [1] 2
Created on 2020-01-26 by the reprex package (v0.3.0)