I have this two data.frames:
df1 = data.frame(
"scientific_name"=c("Anchietea ballardii","Anemia patens","Cololobus argenteus"),
"threat_status"=c("VU","EN","EN")
)
> df1
scientific_name threat_status
1 Anchietea ballardii VU
2 Anemia patens EN
3 Cololobus argenteus EN
>
df2 = data.frame(
"scientific_name"=c("Anchietea ballardii","Anemia patens","Cololobus argenteus","Coleocephalocereus pluricostatus", "Dyckia bracteata", "Merianthera parvifolia", "Kielmeyera rupestris"),
"threat_status"=c(NA)
)
> df2
scientific_name threat_status
1 Anchietea ballardii NA
2 Anemia patens NA
3 Cololobus argenteus NA
4 Coleocephalocereus pluricostatus NA
5 Dyckia bracteata NA
6 Merianthera parvifolia NA
7 Kielmeyera rupestris NA
>
I need to fill the df2$threat_status with the correspondent df1$threat_status, but when there is not any value for the column df2$threat_status it can be filled with "LC". I'm trying with sqldf INSERT TO, but it's not working. I's like to have a solution in plain R, something tells me it would be more elegant. Somebody could help? Thanks a lot!