update sql and r scripts