RE: [R] Weird problem with median on a factor

2003-11-03 Thread RBaskin
to factor or to the functions themselves. Thanks Bob -Original Message- From: Duncan Murdoch [mailto:[EMAIL PROTECTED] Sent: Sunday, November 02, 2003 9:40 AM To: Peter Dalgaard Cc: [EMAIL PROTECTED] Subject: Re: [R] Weird problem with median on a factor On 02 Nov 2003 12:50:37 +0100, you

RE: [R] Weird problem with median on a factor

2003-11-03 Thread Prof Brian Ripley
On Mon, 3 Nov 2003 [EMAIL PROTECTED] wrote: Continuing to beat the greasy spot in the road where the dead horse used to be 1) I know that the people building r are working on bigger and better things than this silly question and I appreciate the existence of this complicated package

Re: [R] Weird problem with median on a factor

2003-11-02 Thread Christoph Bier
Dave Cacela schrieb: Christoph, I concur with the other respondents who questioned why someone would wish to calculate the median of a factor. However, with regard to your actual question, I suspect that median() is giving different answers because the two vectors are not both factors, i.e., that

Re: [R] Weird problem with median on a factor

2003-11-02 Thread Peter Dalgaard
Christoph Bier [EMAIL PROTECTED] writes: Dave Cacela schrieb: Christoph, I concur with the other respondents who questioned why someone would wish to calculate the median of a factor. However, with regard to your actual question, I suspect that median() is giving different answers

Re: [R] Weird problem with median on a factor

2003-11-02 Thread Duncan Murdoch
On 02 Nov 2003 12:50:37 +0100, you wrote: (Arguably, sorting an unordered factor ought to Verboten as well, though!) No, arbitrarily assigning an ordering and using that to sort is a useful thing in many situations, e.g. searching. Duncan Murdoch

Re: [R] Weird problem with median on a factor

2003-11-02 Thread Christoph Bier
Peter Dalgaard wrote: Christoph Bier [EMAIL PROTECTED] writes: Dave Cacela schrieb: Christoph, I concur with the other respondents who questioned why someone would wish to calculate the median of a factor. However, with regard to your actual question, I suspect that median() is giving different

RE: [R] Weird problem with median on a factor

2003-10-31 Thread Simon Fear
What do you expect the median of a factor to be? Are you sure you don't want the *mode* (most common value)? If you want the median numeric code of ordered factors, maybe use `as.numeric` first. Consider what you think should happen if this median is not an integer. HTH -Original

Re: [R] Weird problem with median on a factor

2003-10-31 Thread Peter Dalgaard
Christoph Bier [EMAIL PROTECTED] writes: The following works: median(fbhint.spss1[,264], na.rm=T) [1] sehr wichtig Levels: sehr wichtig wichtig teils/teils unwichtig ganz unwichtig ... but here it doesn't: median(fbhint.spss1[,566], na.rm=T) Error in Summary.factor(..., na.rm =

Re: [R] Weird problem with median on a factor

2003-10-31 Thread Christoph Bier
Peter Dalgaard wrote: Offhand, I'd guess that the median is inbetween two factor levels in one case and not in the other. Hm, maybe. A problem, that would not occur, if I used the median on the numeric data of this factor. However, both cases should give an error, especially for unordered

Re: [R] Weird problem with median on a factor

2003-10-31 Thread Christoph Bier
Simon Fear schrieb: The last part of my message is what I thought might be the cause - maybe your median is not an integer, so what category should it be mapped to? What do you get if you slip in an `as.numeric` before calculating the median? [if still an error, then there is definitely something

RE: [R] Weird problem with median on a factor

2003-10-31 Thread Simon Fear
Final guess as to observed behaviour: in the first case after removal of NAs there were an odd number of observations (so that sum was not called within the code for median). In your second call I suspect that even though you got an integer answer, it was found as sum(2,2)/2. It seems to me the

RE: [R] Weird problem with median on a factor

2003-10-31 Thread RBaskin
. off Thanks Bob Usual disclaimers -Original Message- From: Simon Fear [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 6:18 AM To: Christoph Bier Cc: [EMAIL PROTECTED] Subject: RE: [R] Weird problem with median on a factor Final guess as to observed behaviour: in the first

RE: [R] Weird problem with median on a factor

2003-10-31 Thread Tony Plate
Thanks Bob Usual disclaimers -Original Message- From: Simon Fear [mailto:[EMAIL PROTECTED] Sent: Friday, October 31, 2003 6:18 AM To: Christoph Bier Cc: [EMAIL PROTECTED] Subject: RE: [R] Weird problem with median on a factor Final guess as to observed behaviour: in the first case after