vendredi 28 mai 2021

R - Copy negative sign from one to another column

I have a dataframe (df_ann) as shown here:

Cha Seg_value Seg_value2
AXL2 -0.654 2.965
PTT1 1.957 1.84
AXL2 2.654 0.989
PTT1 -1.038 0.85

I want to add the negative sign in the Seg_value2 column if it is present in the Seg_value column.

Output should be:

Cha Seg_value Seg_value2
AXL2 -0.654 -2.965
PTT1 1.957 1.84
AXL2 2.654 0.989
PTT1 -1.038 -0.85

I have searched for the solution to the problem but did not find the answer. Anything would be helpful.

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire