R Lesson 5 – Mathematical Functions

Today we’ll be looking at writing some functions in R, with the goal being to create functions that can perform mathematical equations. For example we can make a function f(x) that takes an input and returns some output value:

With that in mind, you can then plot the function:

So you see that it is possible to create a mathematical equation in R.

Given that fact, it should then be possible to do other mathematical things in R. One thing we can do is solve a system of differential equations:

Or this same process can be used to solve higher order differential equations.

R also has a function ODE which can be used to solve ordinary differential equations.

Since the language primarily utilizes vectors and matrices, it makes sense that you’d be able to do singular value decomposition, as well as finding the covariance matrix.

At the end of the day, R is a language that was primarily developed for mathematics. It makes a lot of sense that maths would be a core focus.

That will wrap up our R tutorial series. I hope you enjoyed the brief look at getting started with R and go on to use R more in the future!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Design a site like this with WordPress.com
Get started