R is a powerful, open source, functional programming language. It can be used for a wide range of programming tasks …