I have a dataframe named DF, with three columns: longitude, latitude, and values. How to process DF, so that the longitude and latitude fall within a smaller sample DF_include?
DF
lon lat value
-105.3125 39.9375 21
-105.4375 39.9375 10
-105.3125 40.0625 16
-105.4375 40.0625 11
...
DF_include
lon lat
-105.3125 39.9375
-105.4375 40.0625
...
I tried the code below, but it does nothing to DF, thanks for your help.
DF_sub = subset(DF, (lon = DF_include$lon)&(lat = DF_include$lat))
I have a follow up question. Besides choosing the "DF_include" grid cells, is it possible to fill the other cells with NAs in "DF" and still maintain the rectagular shape of "DF"? Right now, the grid cells not in "DF_include" are blank, and I want to have NAs for them in "DF". Thanks again.