How to retrieve elements from a data frame?