How to replace NAs of a variable with values from another dataframe
问题 i hope this one isn´t stupid. I have two dataframes with Variables ID and gender/sex. In df1, there are NAs. In df2, the variable is complete. I want to complete the column in df1 with the values from df2. (In df1 the variable is called "gender". In df2 it is called "sex".) Here is what i tried so far: #example-data ID<-seq(1,30,by=1) df1<-as.data.frame(ID) df2<-df1 df1$gender<-c(NA,"2","1",NA,"2","2","2","2","2","2",NA,"2","1","1",NA,"2","2","2","2","2","1","2","2",NA,"2","2","2","2","2",NA)