[R] Finding the median
Sarah Goslee
sarah.goslee at gmail.com
Mon Mar 12 16:59:25 CET 2012
I'd start by using if().
If you can convince the list that this isn't homework, you might get more help.
Sarah
On Mon, Mar 12, 2012 at 7:15 AM, <elliot.welch at virgin.net> wrote:
> Hi just a quick question in which I must use the "function and return" part of R.
>
> If I was asked to define a function called "median" where the function has a single argument x and returns the median value of a vector. How would I go about saying the median = element x in terms of n (say (n + 1)/2 or whatever it would be) if there is an even amount of elements, or x in terms of n (with a different way of saying how many n) if there is an odd amount of elements?
>
> Much appreciated
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list