Vintage analysis in R for PostgreSQL data