substring variables and adding them to dataframe