debug tables, add R code, add select query