> 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
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
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
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
> 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
> 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
> 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:
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:
>
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(
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
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
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
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
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
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
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
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
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
18 matches
Mail list logo