Re: [Rd] median and data frames

2011-10-08 Thread Martin Maechler
> Martin Maechler > on Fri, 29 Apr 2011 16:25:09 +0200 writes: > Paul Johnson > on Thu, 28 Apr 2011 00:20:27 -0500 writes: >> On Wed, Apr 27, 2011 at 12:44 PM, Patrick Burns >> wrote: >>> Here are some data frames: >>> >>> df3.2 <- data.frame(1:3, 7

Re: [Rd] median and data frames

2011-05-05 Thread Joshua Ulrich
On Fri, Apr 29, 2011 at 9:25 AM, Martin Maechler wrote: >> Paul Johnson >>     on Thu, 28 Apr 2011 00:20:27 -0500 writes: > >    > On Wed, Apr 27, 2011 at 12:44 PM, Patrick Burns >    > wrote: >    >> Here are some data frames: >    >> >    >> df3.2 <- data.frame(1:3, 7:9) >    >> df4.2

Re: [Rd] median and data frames

2011-04-30 Thread Tim Hesterberg
I also favor deprecating mean.data.frame. One possible exception would be for a single-column data frame. But even here I'd say no, lest people expect the same behavior for median, var, ... Pat's suggestion of using stop() would work nicely for mean. (but omit paste - stop handles that). Tim Hes

Re: [Rd] median and data frames

2011-04-29 Thread Patrick Burns
If Martin's proposal is accepted, does that mean that the median method for data frames would be something like: function (x, ...) { stop(paste("you probably mean to use the command: sapply(", deparse(substitute(x)), ", median)", sep="")) } Pat On 29/04/2011 15:25, Mart

Re: [Rd] median and data frames

2011-04-29 Thread Hadley Wickham
> My personal oppinion is that  mean.data.frame() should never have > been written. > People should know, or learn, to use apply functions for such a > task. > > The unfortunate fact that mean.data.frame() exists makes people > think that median.data.frame() should too, > and then > >  var.data.fra

Re: [Rd] median and data frames

2011-04-29 Thread William Dunlap
> From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Martin Maechler > Sent: Friday, April 29, 2011 7:25 AM > To: Paul Johnson > Cc: r-devel > Subject: Re: [Rd] median and data frames > [ ... lots of lines elided ... ] > My

Re: [Rd] median and data frames

2011-04-29 Thread Martin Maechler
> Paul Johnson > on Thu, 28 Apr 2011 00:20:27 -0500 writes: > On Wed, Apr 27, 2011 at 12:44 PM, Patrick Burns > wrote: >> Here are some data frames: >> >> df3.2 <- data.frame(1:3, 7:9) >> df4.2 <- data.frame(1:4, 7:10) >> df3.3 <- data.frame(1:3, 7:9, 10:

Re: [Rd] median and data frames

2011-04-28 Thread S Ellison
This seems trivially fixable using something like median.data.frame <- function(x, na.rm=FALSE) { sapply(x, function(y, na.rm=FALSE) if(is.factor(y)) NA else median(y, na.rm=na.rm), na.rm=na.rm) } >>> Paul Johnson 28/04/2011 06:20 >>> On Wed, Apr 27, 2011 at 12:44 PM, Patrick Burns wrote: >

Re: [Rd] median and data frames

2011-04-27 Thread Paul Johnson
On Wed, Apr 27, 2011 at 12:44 PM, Patrick Burns wrote: > Here are some data frames: > > df3.2 <- data.frame(1:3, 7:9) > df4.2 <- data.frame(1:4, 7:10) > df3.3 <- data.frame(1:3, 7:9, 10:12) > df4.3 <- data.frame(1:4, 7:10, 10:13) > df3.4 <- data.frame(1:3, 7:9, 10:12, 15:17) > df4.4 <- data.frame(

Re: [Rd] median and data frames

2011-04-27 Thread peter dalgaard
On Apr 27, 2011, at 19:44 , Patrick Burns wrote: > I would think a method in analogy to > 'mean.data.frame' would be a logical choice. > But I'm presuming there might be an argument > against that or 'median.data.frame' would already > exist. Only if someone had a better plan. As you are probabl

[Rd] median and data frames

2011-04-27 Thread Patrick Burns
Here are some data frames: df3.2 <- data.frame(1:3, 7:9) df4.2 <- data.frame(1:4, 7:10) df3.3 <- data.frame(1:3, 7:9, 10:12) df4.3 <- data.frame(1:4, 7:10, 10:13) df3.4 <- data.frame(1:3, 7:9, 10:12, 15:17) df4.4 <- data.frame(1:4, 7:10, 10:13, 15:18) Now here are some commands and their answers

[Rd] "median" accepting ordered factor

2009-06-13 Thread Christophe Genolini
Hi the list, The function median start by exclude the factor. Indeed, it not possible to calculate the median for a factor, but it is possible to evaluate the median for an ordered factor. Would it be possible to change the median function to accept also ordered factor? This would be helpful sp

Re: [Rd] median methods

2008-04-27 Thread Rob Hyndman
Brian. The example I have in mind is for functional data where there are several ways to define a median. For example, it can be defined as the pointwise median of a set of functions {f_j(x); j=1,...,n}. Or it can be defined as m(x) = arg min_{g(x)} \sum_j |g(x) - f_j(x)| dx. The latter can be calc

Re: [Rd] median methods

2008-04-26 Thread Prof Brian Ripley
On Sat, 26 Apr 2008, Rob Hyndman wrote: > Can we please have a ... argument in median() to make it possible to pass > arguments to specific methods. Not without a reasoned case -- see 'Writing R Extensions' as to why it is a non-trivial change that affects all existing methods (and there are so

[Rd] median methods

2008-04-26 Thread Rob Hyndman
Can we please have a ... argument in median() to make it possible to pass arguments to specific methods. _ Rob J Hyndman Professor of Statistics, Monash University Editor-in-Chief, International Journal of Forecasting http://www.robhyndman.info/ [[alternative

Re: [Rd] Median

2007-05-08 Thread R. Villegas
2007/5/8, Jose Sierra <[EMAIL PROTECTED]>: > Hello. > > I need calculate the median of several column of a data.frame, in a new > column of this data frame, but the median operator only calculate from a > vector. > > I have made a functionc that calculate the median but it is very slow. > Are there

Re: [Rd] Median

2007-05-08 Thread José Fernández Menéndez
i don't understand very well but apply(your_data_frame, 1,median) calculates the median of every row of your data frame apply(your_data_frame, 2, median) calculates the median of every column 2007/5/8, Jose Sierra <[EMAIL PROTECTED]>: > Hello. > > I need calculate the median of several column of

[Rd] Median

2007-05-08 Thread Jose Sierra
Hello. I need calculate the median of several column of a data.frame, in a new column of this data frame, but the median operator only calculate from a vector. I have made a functionc that calculate the median but it is very slow. Are there any method in any package to calculate this? Best re