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? Thanks, Corinna
513 %/% 100 513 %% 100 check ?"%/%" for more info. Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Schmitt, Corinna" <Corinna.Schmitt at igb.fraunhofer.de> To: <r-help at stat.math.ethz.ch> Sent: Friday, March 30, 2007 3:34 PM Subject: [R] math-operations> 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? > > Thanks, Corinna > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
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
On Friday 30 March 2007 14:34, 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 = 5trunc(513 / 5)> 513 mod 100 = 13513 %% 100> > How can I get this in R-syntax? > > Thanks, Corinna > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide commented, minimal, > self-contained, reproducible code.-- Alberto G. Murta IPIMAR - Portuguese Institute of Fisheries and Marine Research Avenida de Brasilia s/n; 1449-006 Lisboa; Portugal Tel: +351 213027120; Fax: +351 213015948; email: amurta at ipimar.pt
Dimitris Rizopoulos wrote:> > 513 %/% 100 > > 513 %% 100 >Now this is a great opportunity to improve the R-Wiki. What about a "Pascal" page in the R-Wiki, where a list of Pascal-to-R translations would be available? Alberto Monteiro