Specifically I have an untidy data.frame with subspecies varieties in separate columns, like this;
# Data
Genus<- c("Metrosideros", "Gahnia", "Acacia")
Species<- c("polymorpha", "aspera", "koa")
Subspecies<- c("", "globosa","")
Variety<- c("glaberrima", "", "")
df<-data.frame(Genus, Species, Subspecies, Variety)
But I want a new column that looks like this;
df$Sciname<- c("Metrosideros polymorpha var. glaberrima",
"Gahnia aspera subsp. globosa",
"Acacia koa")
There is probably a clever solution using paste() and ifelse() but I cannot figure it out. If there is a tidyverse (dplyr) solution that is welcome. Thanks for any help!