function with condition

how to write the following function in R

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

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

Please stop duplicating this topic