Skip to Content
Learning R Programming
book

Learning R Programming

by Kun Ren
October 2016
Beginner to intermediate
582 pages
11h 26m
English
Packt Publishing
Content preview from Learning R Programming

Using math functions

Mathematical functions are an essential part in all computing environments. R provides several groups of basic math functions.

Basic functions

The basic functions include square root, and exponential and logarithm functions as the following table shows:

Basic functions

Note that sqrt() only works with real numbers. If a negative number is supplied, NaN will be produced:

sqrt(-1)
## Warning in sqrt(-1): NaNs produced
## [1] NaN 

In R, numeric values can be finite, infinite (Inf and -Inf), and NaN values. The following code will produce infinite values.

First, produce a positively infinite value:

1 / 0
## [1] Inf 

Then, produce a negatively infinite ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn R programming

Learn R programming

David Wilkins
R Programming By Example

R Programming By Example

Omar Trejo Navarro
Efficient R Programming

Efficient R Programming

Colin Gillespie, Robin Lovelace

Publisher Resources

ISBN: 9781785889776Supplemental Content