Hi All,
I need to find matched and unmatched vector values from another vector. Below is the code.
Name <-c("Alex","Rabert", "Lily","Sara")
Letter <-c("A","R","L","S")
df<- data.frame(Name,Letter)
result <- match(c("A", "R"), df$Letter)
df<- data.frame(Name,Letter,result)
print(df)
below is the result from above code. Here i could see 1 and 2 displayed repeatedly which is wrong.
for last two rows result column should have NA NA. Kindly help.
Name Letter result
Alex A 1
Rabert R 2
Lily L 1
Sara S 2
expected as below
Name Letter result
Alex A 1
Rabert R 2
Lily L NA
Sara S NA