Skip to content
Back to formatted view

Raw Message

Message-ID: <2B79EAB2-3D67-4FD6-ABD0-BBA573495E20@virginia.edu>
Date: 2006-12-19T11:49:51Z
From: Michael Kubovy
Subject: how to replace some objects?
In-Reply-To: <3f2938d50612190005h2b0f56c0h952e19f53081b944@mail.gmail.com>

On Dec 19, 2006, at 3:05 AM, Zhang Jian wrote:

> I want to replace some objects in one row or column.For example,
> One colume: a,b,a,c,b,b,a,a,c.
> I want to replace "a" with "1", "b" with "2", and "c" with "3".
> Like this: 1,2,1,3,2,2,1,1,3.

let <- c('a', 'b', 'a', 'c', 'b', 'b', 'a', 'a', 'c')
library(car)
num <- recode(let, " 'a' = 1; 'b' = 2; else = 3 ")

_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
         McCormick Road    Charlottesville, VA 22903
Office:    B011    +1-434-982-4729
Lab:        B019    +1-434-982-4751
Fax:        +1-434-982-4766
WWW:    http://www.people.virginia.edu/~mk9y/