Functions for dealing with data frame databases in R