I have two dataframes both of which contain the same variable and a unique id for each observation.
df.1 is a large dataset which contains missing values denoted by an NA. The values for those missing entries are contained within df.2 and I would like to replace the missings from df.1 with the values from df.2 by matching the id's.
I haven't been able to find a similar issue on here which takes into account them both being factor variables.
To make things simpler: if the id's match - the missing value from df.1 should be replaced with the factor value from df.2.
df.1 <- data.frame(id = c(334,440,501,2304,2500),
v1 = c("4 dogs",NA,"3 dogs",NA,"No dogs"))
df.2 <- data.frame(id = c(440,2304),
v2 = c("4 dogs","5 dogs"))
Your help is much appreciated.