I'm trying to utilise R's "where" function in a loop to select a certain row from two datasets based on a matching element, and then plot the two together in a scatterplot. The row names of the two dataframes, as well as the loop, are provided in the code sample below. There are more counties in each dataframe than are listed in "mycounties."
I have used the "where" function in a loop exactly like this before, but this time R is returning the error message that "where" doesn't exist? I know "where" exists! My question is, how do I make R recognize this "where" structure, or is there a better way to pick out the rows I want to plot?