-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpert1.R
More file actions
36 lines (28 loc) · 1.14 KB
/
expert1.R
File metadata and controls
36 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# The following code takes two data frames and checks both
#name1 and name2 in each to find a match
#presently it only finds the exact matches but could be tailored
# to find partially iterating each call to expertcall() function
# with substrings from name1 and name2 :e.g groups of four
#or more consecutives letters also it could be made more expert
#by not matching Mr., Ms.,Prof., Prof, Abdul, Dr.,Dr etc.
# and substituting Mohd or M[[:space::]] or M. for Mohammad or
# Muhammad and A[[:space:]] or A. for Ahmed etc.
# FOR NOW expertcall function could be used alone by passing
# manually such partial strings i.e. parts of name1 and name2
expert1 <- function(){
ptm<- read.csv('ptmfaculty.csv',header=T,colClasses='character')
f <- read.csv('smbfaculty.csv',header=T, colClasses='character')
expert(ptm$Department, ptm$Name, cbind(f$Name,f$Department))
}
expert <- function( name1, name2, f)
{
# f is a data frame with two columns to search against name1 and name2
for (i in 1:length(name1))
{
expertcall(name1[i],name2[i],f)
}
}
expertcall <- function(n2, n1, f)
{
print( agrep(n1,f[agrep(n2,f[,2], ignore.case=T),1],ignore.case=T,value=T))
}