[R] math-operations

Duncan Murdoch murdoch at stats.uwo.ca
Fri Mar 30 15:43:39 CEST 2007


On 3/30/2007 9:34 AM, Schmitt, Corinna wrote:
> Hallo R-experts,
> 
> for a function I need to work with the commands "div" and "mod" known
> from Pascal and Ruby. The only help I know is "ceiling()" and "floor()"
> in R. Do "div" and "mod" exist? When yes please send me a little
> example.
> 
> In Pascal-Syntax I want: 
> 513 div 100 = 5
> 513 mod 100 = 13
> 
> How can I get this in R-syntax?

div is %/% and mod is %%.  These (and the other arithmetic operators in 
R) are described in the ?Arithmetic help topic.  The full list of all 
operators is in the "R Language Definition" manual, near the start of 
the "Evaluation of expressions" chapter.

Duncan Murdoch



More information about the R-help mailing list