Refined function to generate xyplot-compabible data frames