s-news
[Top] [All Lists]

Re: Removing levels from a factor

To: "Terry Therneau" <therneau@mayo.edu>, <s-news@lists.biostat.wustl.edu>, <Mark.Hearnden@nt.gov.au>
Subject: Re: Removing levels from a factor
From: "Thompson, David (MNR)" <David.John.Thompson@ontario.ca>
Date: Wed, 5 Mar 2008 10:07:02 -0500
In-reply-to: <200803051405.m25E50F20954@hsrnfs-101.mayo.edu>
References: <200803051405.m25E50F20954@hsrnfs-101.mayo.edu>
Thread-index: Ach+yhRxPBtiGoULSEKV3Q7aaK7vBAABdzGw
Thread-topic: [S] Removing levels from a factor
Terry,

Regarding the 'factors are only occasionally useful' comment,
what are the situations where factors are _actually_ useful?
Do not (most?) modelling functions that require factors usually
coerce character values as required?

Thanks, DaveT.
*************************************
Silviculture Data Analyst
Ontario Forest Research Institute
Ontario Ministry of Natural Resources
david.john.thompson@ontario.ca
http://ofri.mnr.gov.on.ca
*************************************
>-----Original Message-----
>From: s-news-owner@lists.biostat.wustl.edu 
>[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of 
>Terry Therneau
>Sent: March 5, 2008 09:05 AM
>To: s-news@lists.biostat.wustl.edu; Mark.Hearnden@nt.gov.au
>Subject: Re: [S] Removing levels from a factor
>
> The easiest thing is to turn off factors:
> 
> > options(stringsAsFactors=F)
> > data$Treatment <- as.character(data$Treatment)
> 
> Now you can subset the data frame and things will work as you would
anticipate.
> 
> Comment: factors are occassionaly useful, but only occasionally.  Much
grief 
>can be avoided by turning them off by default.  Our biostat group (>100
people, 
>over 1200 projects a year) has had the above option as a part of our
global 
>defaults for many years, and has not yet seen a downside to the
decision.
> 
>       Terry Therneau
>       Mayo Clinic
>--------------------------------------------------------------------
>This message was distributed by s-news@lists.biostat.wustl.edu.  To
>unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
>the BODY of the message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>