Course Content
R Introduction: Part I
1. Basic Syntax and Operations
R Introduction: Part I
Integer Division and Remainders
Integer division is a common mathematical operation that we often use in daily life, sometimes without even realizing it.
Take, for instance, the scenario where you have 16 candies and want to divide them equally among three friends. Each friend would get five candies, with one candy left over, since 16 equals 5 times 3 plus 1. We say that the result of the integer division of 16
by 3
is 5
, and the remainder of this division is 1
.
In R, these operations are performed using:
%/%
for integer division.%%
for the remainder of a division.
To calculate the given example in R, you would use:
Task
For the following exercises:
- Compute how many complete days there are in
435
hours. - Determine how many hours would be left over.
Keep in mind that a day is comprised of 24 hours.
Everything was clear?
Section 1. Chapter 4