Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Text values
Variables
Functions
Summary
24. R basics - summary

Instruction

We're almost done with Part 1 of the course! We've covered quite a lot of information here, so let's do a quick recap.

R knows how to work with number and text values. With numeric values, you can perform various calculations: addition (5+4), subtraction (5-1), multiplication (15*4), division (5/4). Text values are surrounded with single or double quotes ("Mary" or 'Mary').

The results of calculations can be stored in a variable:

weight <- 75

Variables can be used in further calculations, e.g.:

weight + 10

You can compare values saved in variables with other values using comparison operators (e.g. height < 160). Such comparisons return a single logical value: TRUE or FALSE.

R has many built-in functions that perform all kinds of predefined calculations. A function is called by its name. In parentheses, you pass in the arguments to the function:

round(15.2)

There are functions that work with number values (like round) and those that work with text values (nchar, substr). You can get more information about a function by using the help operator followed by the function name, like so:

?functionname

You can also write comments in R. A comment is anything that follows # on a single line. These serve no other purpose than to document your code. That's about it! It's time to test what you've learned. Ready?

Exercise

Click the Next exercise to begin the first exercise.