Skip to content

Instantly share code, notes, and snippets.

@mgcdanny
Created October 2, 2012 03:00
Show Gist options
  • Save mgcdanny/3815922 to your computer and use it in GitHub Desktop.
Save mgcdanny/3815922 to your computer and use it in GitHub Desktop.
Fuzzy Variable Name Check
###Variable Name Checking ##########
pop = read.csv("H:\\file1.csv", head=T, as.is=T)
sam = read.csv("H:\\file2_vars_10.csv", head=T, as.is=T)
p = pop$NAME[!(pop$NAME %in% sam$NAME)]
s = sam$NAME[!(sam$NAME %in% pop$NAME)]
res = data.frame()
for (i in 1:length(p)) {
for (j in 1:length(s)) {
temp = adist(p[i],s[j])
if(temp < 4) res = rbind(res,cbind(temp,p[i],s[j]))
}
}
View(res[order(res[1], decreasing=T),])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment