[R tuto] split up too large code