s-news
[Top] [All Lists]

Re: Simple recode problem

To: Jan Ivanouw <ivanouw@post8.tele.dk>
Subject: Re: Simple recode problem
From: Chuck Cleland <ccleland@optonline.net>
Date: Mon, 05 Nov 2007 17:58:20 -0500
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <001701c81ffe$21447d30$6401a8c0@JansAthlon64>
References: <64E0B1A1FF5F1B4497212A108E11118F31F569@MAPIUDEM2.sim.umontreal.ca> <001701c81ffe$21447d30$6401a8c0@JansAthlon64>
User-agent: Thunderbird 2.0.0.6 (Windows/20070728)
Jan Ivanouw wrote:
> I am sorry for my lack of knowledge.
> 
> I have a data frame with a variable (column) containing the integers 1,
> 2, 3, 4 and 5.
> I want to recode the variable so 5=1, 4=2, 3=3, 2=4 and 1=5.
> 
> How do I do that?

> X <- sample(1:5, 20, replace=TRUE)

> X
 [1] 4 1 2 1 2 1 3 4 3 1 2 2 5 5 3 5 3 5 1 3

> 6 - X
 [1] 2 5 4 5 4 5 3 2 3 5 4 4 1 1 3 1 3 1 5 3

> Jan Ivanouw PhD
> Dep of Health Psychology
> University of Copenhagen
> Denmark
> 
> 
> --------------------------------------------------------------------
> 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 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

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