Skip to content
Prev 276311 / 398506 Next

Reclassify string values

On Thu, Nov 3, 2011 at 1:31 PM, Zev Ross <zev at zevross.com> wrote:
But of course, except sometimes you have to write the function yourself.

reclassify = function(data, inCategories, outCategories)
{
   outCategories[ match(data, inCategories)]
}

Sorry I can't make it any simpler than a 1-line solution :)

Feel free to add some checking of input validity, if you need that.

Peter