Advanced Analytics R scripts