mercredi 3 mars 2021

if else with multiple conditions and multiple statements [duplicate]

I need a little help with making a column in a dataframe that says if the value is "positive", "negative" or "intermediate"for each individual row in the given column, but I can't get it to run.

I want the column with rows saying that the value is positive if it is larger than calib$avg_Abs_st_SBA, negative if the value is smaller than SBA$avg_Abs_st_SBA or intermediate if the value is between calib$avg_Abs_st_SBA and SBA$avg_Abs_st_SBA.

I have been trying this code without success

summ_plate_x$Status <- if(summ_plate_x$avg_Abs_st_SBA > calib$avg_Abs_st_SBA) { "Positive" } else if (summ_plate_x$avg_Abs_st_SBA < SBA$avg_Abs_st_SBA) { "Negative" } else { "Intermediate" }

Aucun commentaire:

Enregistrer un commentaire