I am a new learner in R. I wanted to see if I\'ve improved, so I tried to optimize a function which I wrote few weeks before again with the new things I\'ve learned. I