Vectorized if [🇷 for BE/BA]

posted by d_labes  – Berlin, Germany, 2016-09-21 15:32 (3542 d 23:05 ago) – Posting: # 16659
Views: 5,797

Dear öberster größter Meister!

❝ 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)


Vectorized if comes to rescue.
a <- ifelse(a<4, a, a-1)

Hope this helps and matches your problem.

BTW: Hardcore Rusers never use = for assignments :no:

Regards,

Detlew

Complete thread:

UA Flag
Activity
 Admin contact
23,653 posts in 4,991 threads, 1,570 registered users;
450 visitors (0 registered, 450 guests [including 18 identified bots]).
Forum time: 14:37 CEST (Europe/Vienna)

I’m all in favor of the democratic principle
that one idiot is as good as one genius, but I draw the line
when someone takes the next step and concludes
that two idiots are better than one genius.    Leo Szilard

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