So I have a data frame like this, with names of species present in three countries, with some NAs in countries where a certain species does not exist:
Country_A | Country_B | Country_C
-----------------------------------------------------
Tilapia guineensis | NA | Tilapia guineensisi
Tilapia zillii | Tilapia zillii | Tilapia zillii
NA | Fundulus rubrifrons | Fundulus rubrifrons
Eutrigla gurnardus | Eutrigla gurnardus | NA
Sprattus sprattus | NA | NA
What I'm trying to do is basically check if a species is present in either one, two or three countries and make a data frame to look something like this:
Species name | Country_A | Country_B | Country_C
---------------------------------------------------------------------
Tilapia guineensis | present | not_present | present
Tilapia zillii | present | present | present
Fundulus rubrifrons | not_present | present | present
Eutrigla gurnardus | present | present | not_present
Sprattus sprattus | present | not_present | not_present
I think maybe using the spread function can be a way to go, or the ifelse function, but I don't really know how to implement it. Thank you so much for any answer