So I have a list of 2500 places that I've tried geocoding. Roughly 97 won't geocode. However a while ago someone went through by hand and geocoded these. I've left joind the newest list of geocoded places with the old hand-geocoded table. I'd like to replace the missing/bad geocodes with the hand-geocoded records. The data looks something like this
NewLat OldLat Flag
29.019 39.213 1
41.23 41.23 0
NA 38.13 1
0.00 41.29 0
I'd like it so that the following happens:
If the NewLat is NA or 0.00, replace the value with the OldLat If the record has a Flag of 1, replace with the OldLat.
so far I have
df$NewLat[is.na(df$NewLat)]<-df$OldLat
but the second part is stumping me. I've tried
if("1"%in%df$Flag){df$NewLat=df$OldLat}
and elseif (df$Flag =1) {df$NewLat=df$OldLat}
and mutate(df, df$NewLat = ifelse(df$NewLat<1.0,df$OldLat,df$NewLat))
but nothing seems to be working.
Any suggestions?
Aucun commentaire:
Enregistrer un commentaire