Chapter 17
LURN… To Use R as a Scientific Calculator

This chapter explains how to use R as a scientific calculator, including its use of trigonometric functions. We’ll also plot some of the functions for illustrative purposes.

17.1 Trigonometric functions

R has a series of commands that all perform quite similarly. The only real issue is to find out what actual commands get what we want. First of all, we need to know how R will work with degrees or radians.

  > pi

  [1] 3.142

  > sin(pi/6)

  [1] 0.5

  > sin(30)

  [1] -0.988

So our experiment shows us that R is working in radians.

The functions sin(), cos(), and tan() give the sine, cosine, and tangent respectively. To find the inverse sine, sometimes called the arcsine, we use the asin() command. The hyperbolic functions associated with these functions also exist; use sinh(), cosh() and tanh() and for the inverse, just add an extra a before the command named here.

17.2 Graphs of trigonometric functions