I have a data set containing state city names (i.e. NY NEW YORK), but some of the location names are not correct. There are instances where the location is misspelled or has missing spaces ( i.e. NY NEWW YORK or NY NEWYORK). I have an excel file with all the correct city names and wondering if there is a way to do some type of look up to that file and make the correction in my R script.
My excel reference file is set up like such:
CurrentOrigin CorrectOrigin
NY NEW YORK NY NEW YORK
NY NEWW YORK NY NEW YORK
I've tried writing an if statement but had no luck.
My R skills are limited, but I am making strides everyday.
if (df$Origin == df2$CurrentOrigin) {
df2$CorrectOrigin ##not sure what to put in the statement
}
Any help would be great! Thank you in advance!