[R] If else
Rolf Turner
r.turner at auckland.ac.nz
Sun Nov 1 00:59:28 CET 2015
Ted: You are either being deliberately obtuse or playing Devil's
advocate or just stirring. It is clear from his/her posts that the OP
has limited understanding of both R and statistics. Your sophisticated
philosophising about the possibility of "three sexes" is very unlikely
to have anything to do with what the OP wishes to accomplish.
The advice requested was not about how to treat "NA" as a "third sex"
but about how to convert categorical data coded as NA, "M", and "F" to
numeric. Which cannot possibly be a good idea.
It is not productive to encourage the OP to persist with wrong-headed
notions. Instead he or she should be encouraged to get to grips with
the real issues of the analysis and to understand that treating
categorical data as numeric is a recipe for disaster.
cheers,
Rolf
--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
On 01/11/15 08:47, Ted Harding wrote:
> [Apologies if the message below should arrive twice. When first
> sent there was apparently something wrong with the email address
> to r-help, and it was held for moderation because "Message has
> implicit destination" (whatever that means). I have made sure
> that this time the email address is correct.]
>
> John Fox has given a neat expression to achieve the desired result!
>
> I would like to comment, however, on the somewhat insistent criticism
> of Val's request from several people.
>
> It can make sense to have three "sex"es. Suppose, for example,
> that the data are records of street crime reported by victims.
> The victim may be able to identify the sex of the preprator
> as definitely "M", or definitely "F". One of the aims of the
> analysis is to investgate whether there is an association
> between the gender of the offender and the type of crime.
>
> But in some cases the victim may not have been able to recognise
> the offender's sex. Then it would have to go in the record as "NA"
> (or equivalent). There can be two kinds of reason why the victim
> was unable to recognise the sex. One kind is where the victim
> simply did not see the offender (e.g. their purse was stolen
> while they were concentrating on something else, and they only
> found out later). Another kind is where the offender deliberately
> disguises their gender, so that it cannot be determined from their
> appearance. This second kind could be associated with a particular
> category of crime (and I leave it to people's lurid imaginations
> to think of possible examples ... ).
>
> Then one indeed has three "sex"es: Male, Female, and Indeterminate,
> for each of which there is a potential assoctiation with type of crime.
> With most analyses, however, a category of "NA" would be ignored
> (at least by R).
>
> And then one has a variable which is a factor with 3 levels, all
> of which can (as above) be meaningful), and "NA" would not be
> ignored.
>
> Hoping this helps to clarify! (And, Val, does the above somehow
> correspond to your objectives).
>
> Best wishes to all,
> Ted
More information about the R-help
mailing list