r_prepare_data function

Prepare data for regression routines