s-news
[Top] [All Lists]

Create new category column in dataframe

To: s-news@lists.biostat.wustl.edu
Subject: Create new category column in dataframe
From: Lim Weiyang <aficionado82@yahoo.com.sg>
Date: Sun, 2 Nov 2008 02:33:31 +0800 (SGT)
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.sg; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type:Message-ID; b=1vunqsrPCXAVvtSFrJXcPqnJDNYpgSxrzVzuyYM96vU0FeQ5AfIqZcqsCtnX+5TQVuCRGy1Y+noD4Tp0RokIknD/kgYJqct0UtsPoAoEXt1OtodFKjqxopOeMWunbZc0BkxwLtysbOA+CMLiKPakvujKqQAyNW8Fjz3a8EALI+8=;
Reply-to: aficionado82@yahoo.com.sg
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>