Re: [R] ! arithmetic

About this list Date view Thread view Subject view Author view Attachment view

From: David Richmond (daver969@yahoo.com)
Date: Sun 16 Feb 2003 - 17:57:37 EST


Message-id: <EF228A69-417B-11D7-9F4E-000393DBCEC2@yahoo.com>

you can create your own function:

> fact <- function(n) prod(1:n)
> fact(3)
[1] 6
> fact(10)
[1] 3628800
> fact(c(3,4))
[1] 6
Warning message:
Numerical expression has 2 elements: only the first used in: 1:n

fact() will work for scalars but doesn't do well with vectors.

Dave Richmond

On Saturday, February 15, 2003, at 07:33 PM, Stan Markus wrote:

>
> Since "!" is a logical operator in R, how does one use it in its
> arithmetic sense, say to calculate x!/y!(N-y)! ?
>
> Thanks!
>
> Stan

______________________________________________
R-help@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:22 EST