Basic R functions for analysis and data transformation