I have two data frames which both have one column:
df1
Server
A
B
c
d
df2
Server
a
f
z
x
I need to check if df1$Server exists in df2$Server. If yes, I need to add a column in df1 and put 1 else put 0.
I have this code, I think the algorithm is right but it does not seem to be working. Any input is appreciated.
for (i in 1:nrow(df1)) {
if (df1[i,1] %in% row.names(df2)) {
df1[i,2]<-c(1)
} else{
df1[i,2]<-(0)
}
}