Re: [R] strange behaviour of median

2010-02-04 Thread Peter Ehlers
Hi Petr, a couple of comments inserted below. Petr PIKAL wrote: Hi r-help-boun...@r-project.org napsal dne 04.02.2010 11:31:51: Petr PIKAL wrote: Hi so do you think I shall fire a bug announcement? I think I rather wait to see if there is some reaction from others. Maybe, there is some re

Re: [R] strange behaviour of median

2010-02-04 Thread Karl Ove Hufthammer
On Thu, 4 Feb 2010 12:04:32 +0100 Karl Ove Hufthammer wrote: > It's not exactly a bug, since 'median' is not documented to work on data > frames (use 'sapply' or 'apply' for that), Note that this is slightly more complicated than what would appear at first sight. Both 'sapply' and 'apply' work

Re: [R] strange behaviour of median

2010-02-04 Thread Karl Ove Hufthammer
On Thu, 4 Feb 2010 09:32:15 +0100 Petr PIKAL wrote: > > median(df1) > [1] 6.5 10.5 > > Rather weird, AFAIK there shall not be an issue with data frame at least I > did not find any in help page. It's not exactly a bug, since 'median' is not documented to work on data frames (use 'sapply' or

Re: [R] strange behaviour of median

2010-02-04 Thread Petr PIKAL
Hi r-help-boun...@r-project.org napsal dne 04.02.2010 11:31:51: > Petr PIKAL wrote: > > Hi > > > > so do you think I shall fire a bug announcement? I think I rather wait to > > see if there is some reaction from others. Maybe, there is some reason > > behind such behaviour. Those simple stat

Re: [R] strange behaviour of median

2010-02-04 Thread Ted Harding
On 04-Feb-10 09:58:36, Petr PIKAL wrote: > Hi > so do you think I shall fire a bug announcement? I think I rather > wait to see if there is some reaction from others. Maybe, there > is some reason behind such behaviour. Those simple statistics tend > to behave differently when operating on data.fra

Re: [R] strange behaviour of median

2010-02-04 Thread Peter Ehlers
Petr PIKAL wrote: Hi so do you think I shall fire a bug announcement? I think I rather wait to see if there is some reaction from others. Maybe, there is some reason behind such behaviour. Those simple statistics tend to behave differently when operating on data.frames so median is not such a

Re: [R] strange behaviour of median

2010-02-04 Thread Petr PIKAL
Hi so do you think I shall fire a bug announcement? I think I rather wait to see if there is some reaction from others. Maybe, there is some reason behind such behaviour. Those simple statistics tend to behave differently when operating on data.frames so median is not such a huge surprise. see

Re: [R] strange behaviour of median

2010-02-04 Thread Ted Harding
Well, I get the same as Petr with R version 2.10.0 (2009-10-26) on Linux. To me, this suggests that median is broken! Any user would, a priori, expect that median() should operate in exactly the same way as mean(). To extend Petr's example: mat <- matrix(1:32, 4,8) df1 <- data.frame(mat) m

Re: [R] strange behaviour of median

2010-02-04 Thread Petr PIKAL
Hi Sorry, as many Windows users I forgot to mention version and platform > version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status Under development (unstable) major 2 minor 11.0

Re: [R] strange behaviour of median

2010-02-04 Thread Mario Valle
Linux 2.9.0 gives: > median(df1) [1] 34 Ever stranger... mario Petr PIKAL wrote: > During some experimentation in preparing R lessons I encountered this > behaviour which I can not explain fully > > mat <- matrix(1:16, 4,4) > df1 <- data.frame(mat) > >> mean(df1) > X1 X2

[R] strange behaviour of median

2010-02-04 Thread Petr PIKAL
During some experimentation in preparing R lessons I encountered this behaviour which I can not explain fully mat <- matrix(1:16, 4,4) df1 <- data.frame(mat) > mean(df1) X1 X2 X3 X4 2.5 6.5 10.5 14.5 Expected, documented > median(df1) [1] 6.5 10.5 Rather weird, AFAIK there shall