syntax of multiple conditions in R script

These lines of codes want to assign 2 variables based on multiple conditions,
instead of using mutate...ifelse syntax , is there elegant way to implement? Thanks in advance!

if type=3 then do;
if exp >.10 then
do;
trgt_lwr_lmt=round((exp)/2,0.001);
trgt_uppr_lmt= round(exp,0.001);
end;
else if exp<=.10 & exp >=.05 then
do;
trgt_lwr_lmt=.03;
trgt_uppr_lmt=.05;
end;
else if exp<.05 then
do;
trgt_lwr_lmt=.005;
trgt_uppr_lmt=.01;
end;
end;

Additional information: values of conditions are from dataset and 2 new columns are created in the input dataset

mutate(case_when (...)) is meant for this

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.