s-news
[Top] [All Lists]

Re: Create new category column in dataframe

To: aficionado82@yahoo.com.sg
Subject: Re: Create new category column in dataframe
From: David L Lorenz <lorenz@usgs.gov>
Date: Mon, 3 Nov 2008 07:25:40 -0600
Cc: s-news@lists.biostat.wustl.edu, s-news-owner@lists.biostat.wustl.edu
In-reply-to: <549137.71949.qm@web76112.mail.sg1.yahoo.com>

Weiyang,
  Check out cut() on the absolute values, abs(), of the variable in questions.
Dave



Lim Weiyang <aficionado82@yahoo.com.sg>
Sent by: s-news-owner@lists.biostat.wustl.edu

11/01/2008 01:33 PM
Please respond to
aficionado82@yahoo.com.sg

To
s-news@lists.biostat.wustl.edu
cc
Subject
[S] Create new category column in dataframe





Dear S-Users,
 
I wonder whether I can create a new factor column with new categories and names derived from a column with numeric values. For example, I wish to have four categories of the following form and names(firstcat, secondcat, thirdcat, fourthcat):
 
Between -1 and 1: firstcat
Between -2 and -1 or between 1 and 2: secondcat
Between -5 and -2 or between 2 and 5: thirdcat
Below -5 or more than 5: fourthcat
 
I have looked at functions cut, factor etc but do not know how to use them for my purpose.
 
Sincerely hope to have some assistance.
 
Thank you.
 
Best Regards,
Weiyang
 
 



New Email names for you!
Get the Email name you've always wanted on the new @ymail and @rocketmail.
Hurry before someone else does!

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