this might be possible for data.frames using nested data.frames. possibly leverage tidyr as in http://blog.rstudio.org/2016/02/02/tidyr-0-4-0/?