On Wed, Sep 30, 2009 at 2:32 PM, Ista Zahn <istaz...@gmail.com> wrote:
> An extremely verbose, but (in my view) easy to understand approach is:
>
>> data.f <- data; data.f[which(data <= 10)] <- levs[1]; data.f[which(data > 
>> 10)] <- levs[2]; data.f <- factor(data.f)
>

All those which()s are unnecessary.  And if you're going to use this
approach I'd recommend initialising data.f with NA's so you can tell
if you missed any cases.

Hadley


-- 
http://had.co.nz/

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to