[R] Reclassifying values within a vector to several other values

Roy Sanderson R.A.Sanderson at newcastle.ac.uk
Tue Nov 29 10:42:12 CET 2005


Dear List

Apologies for such a simple question:

I have a vector of 738 elements, coded with values between 1 and 16 (but
not containing 7, 10, 11 or 13) and wish to recode value 14 to 1, 4 to 2, 1
to 3, 2 to 4 and all other values to 5.  I've been trying to use the
replace function (in base) and %in%, but without success.

Many thanks
Roy
----------------------------------------------------------------------------
-------
Roy Sanderson
Institute for Research on Environment and Sustainability
Devonshire Building
University of Newcastle
Newcastle upon Tyne
NE1 7RU
United Kingdom

Tel: +44 191 246 4835
Fax: +44 191 246 4998

http://www.ncl.ac.uk/environment/
r.a.sanderson at newcastle.ac.uk




More information about the R-help mailing list