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
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
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
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
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
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
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
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 =
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
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
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
.
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
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
13 matches
Mail list logo