I have two shapefiles/dataframes (I can easily convert between types). One contains coordinates that form a boundary line and one contains coordinates for a set of points representing houses. They both have columns containing long and lat with matching column names between the dataframes.
What I would like to do is create a third dataframe that contains a subset of the house points that exist on the left of the boundary, but not the right.
Using if statements to test if a given house point is to the left of the dataframe, I have tried two versions:
df3 <- if(df1$lat < df2$lat){merge(df1,df2)}
df3 <- if(df1$lat[[i]] < df2$lat[[i]){merge(df1,df2)}
The first returns 0 observations and the second doesn't run, yielding Error: object 'i' not found. Suggestions?
edit: here is the first six rows of both dataframes. One of them has 130 rows, and the other has 3000 rows (the house points).
lat long geometry transaction.id
1 -80.12898 25.79037 LINESTRING (-80.12165 25.98... 145045
2 -80.13958 25.94337 LINESTRING (-80.12165 25.98... 240471
3 -80.19615 25.89209 LINESTRING (-80.12165 25.98... 495368
4 -80.12024 25.83410 LINESTRING (-80.12165 25.98... 129341
5 -80.14139 25.78359 LINESTRING (-80.12165 25.98... 146586
6 -80.12744 25.96239 LINESTRING (-80.12165 25.98... 232505
lat long geometry
1 -80.12165 25.98020 LINESTRING (-80.12165 25.98...
2 -80.11889 25.97520 LINESTRING (-80.11889 25.97...
3 -80.11876 25.97795 LINESTRING (-80.11876 25.97...
4 -80.11903 25.97236 LINESTRING (-80.11889 25.97...
5 -80.11918 25.96933 LINESTRING (-80.11903 25.97...
6 -80.11930 25.96639 LINESTRING (-80.11918 25.96...
edit:
v3 <- ifelse(df1$lat < df3$lat, 1, 0)
df3 <- cbind(df1$lat, df1$long, df1$id, v3)
seems to do a clean job! thanks @r2evans but the values are not coming out right. I think it's because the lat and long column in the second dateframe listed above were coerced from an geometric column with two lats and two longs listed using st_geometry