2021年3月24日星期三

Find location in first dataframe of matching rows in two dataframes

I have two dataframes which share some matching coordinates. I want to find the location in xygrid of the rows that match in the two dataframes.

xygrid <- data.frame("x" = c(-175, -165, -155, -145, -135, -125, -115), "y" = c(85, 85, 85, 85, 85, 85, 85))    xygrid2 <- data.frame("x" = c(-165, -145), "y" = c(85, 85))    > xygrid       x  y  1 -175 85  2 -165 85  3 -155 85  4 -145 85  5 -135 85  6 -125 85  7 -115 85    > xygrid2       x  y  1 -165 85  2 -145 85    #Ideal output  > output  [1] FALSE  TRUE FALSE  TRUE FALSE FALSE FALSE    #So that I can extract the location  >   xygrid[output,]       x  y  2 -165 85  4 -145 85    
https://stackoverflow.com/questions/66790854/find-location-in-first-dataframe-of-matching-rows-in-two-dataframes March 25, 2021 at 07:24AM

没有评论:

发表评论