Learning the basics of the R language

Now let's write some code that actually executes something:

1 + 22 + 5 * 43 ^ 4sqrt(81)pi

This code first evaluates three mathematical expressions using the basic operators. As you might expect, R evaluates the expressions using the mathematical operator precedence. The code calls the sqrt() function to calculate and checks the value of the constant for the number pi (π). The base R installation, or the base package, has many built-in constants. You can search the help for all pages that mention constants with ??"constants".

There are many ways to generate sequences of numbers, as you can see from the following code:

rep(1, 5)4:8seq(4, 8)seq(4, 20, by = 3)

The first command replicates the number 1 five ...

Get Data Science with SQL Server Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.