[R] division of decimal number

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Apr 19 18:39:26 CEST 2007


On Thu, 19 Apr 2007, Gavin Simpson wrote:

> On Wed, 2007-04-18 at 16:06 +0100, Barry Rowlingson wrote:
>> Schmitt, Corinna wrote:
>>> Dear R-Experts,
>>>
>>> how can I divide the number 0.285 with 2. I need a function.
>>> Result: 0.285 / 2 = 0.1425
>>
>>   Just get the / operator:
>>
>>  > divide = get("/")
>>  >
>>  > divide(0.285,2)
>>   [1] 0.1425
>>
>> Is that what you want?
>>
>> Barry
>
> You can use the function directly, by quoting it:
>
>> "/"(0.285, 2)
> [1] 0.1425

Quoting by `` is preferred nowadays because that will work in more places 
than "" does: see ?Quotes.  For example

divide <- `/`

simplfies Baz's expression, and is not the same as divide <- "/".


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list