R code for the interactive interface