Smart recoding of vector values [🇷 for BE/BA]

posted by ElMaestro  – Denmark, 2016-09-21 14:59 (3209 d 18:10 ago) – Posting: # 16657
Views: 6,034

Hi all, especially the R experts out there,

I have a vector like
a=c(1,1,2,2,3,5,5,6,6,7,8,8,9,9)
and I would like to rename/reorder/resomething this vector so that
a=c(1,1,2,2,3,4,4,5,5,6,7,7,8,8)

They are actually factor levels.

So far I took a look at reorder, rank, and sort and googled around but I am not really getting anywhere. I have written a clumsy function that does the trick, but I am sure this can be achieved with a one-liner somehow.

Anyone able to tell how?

Thanks a lot in advance and have a great day.:-)

Pass or fail!
ElMaestro

Complete thread:

UA Flag
Activity
 Admin contact
23,427 posts in 4,929 threads, 1,676 registered users;
70 visitors (0 registered, 70 guests [including 23 identified bots]).
Forum time: 09:09 CEST (Europe/Vienna)

Many people tend to look at programming styles and languages like religions:
if you belong to one, you cannot belong to others.
But this analogy is another fallacy.    Niklaus Wirth

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5