Getting back into shape in R and Python