To do this in R, copy the following command:
cor(a$longevity[a$animal!="elephant"],a$gestation[a$animal!="elephant"])
Notice that the correlation between gestation and longevity has changed.
gestation
longevity