Using the function if overlapping

Hello dear colleagues
I want to know how to write the following command in R

if (x>0 & x <1/2), y=8/3*x, if (x>=1/2 & x <1), y=4/3, else y=0

thanks

A post was merged into an existing topic: function and ifelse