--- In sportsci_rtutorial@yahoogroups.com, "Ian
Shrier" <ian.shrier@...> wrote:
>
> Rob
>
> I am going through the tutorial #12. You used the term "x%%2" and
said it is
> even numbers divided by modulo 2 have no remainder. Sorry for my
ignorance,
> but what is "modulo", and have you talked about "%%" before?
>
> Ian
>
Hi Ian,
Good point. I introduced the modulo operator at the beginning of
Session 5. Probably should have explained what a modulo operator is
though.
Wikipedia definition:
The modulo operation finds the remainder of division of one number by
another. Given two numbers, a (the dividend) and n (the divisor), a
modulo n (abbreviated as a mod n) is the remainder, on division of a
by n.
The first number is divided by the second using integer division,
meaning no decimal places are allowed. For instance, the expression
"7 mod 3" would evaluate to 1: Two times 3 equals 6 with a remainder
of 1: 7 = 2*3 + 1
or
"18 mod 4" evaluates to 2: 18 = 4*4 + 2
Since the definition of an even number is that you can divide it by
2, all even numbers will have a reminder of 0. In R, the operator for
modulos operation is %%, which results in the expression "x%%2".
Hope that explains it.
Cheers
Rob