Code to search for a value and retrieve the value to a new column only if certain conditions are met

Hi all, apologies, I am pretty new to R.

My query is I have a dataset output from qualtrics that included randomisation so essentially my data looks like this (barring the last 6 columns - R would only let me upload one image apologies)

The participants in my study have given me the V values. V1 and V2 correspond to Probability 1, V3 and V4 correspond to Probability 2, and V5 and V6 correspond to Prob3. The probabilities are filled in randomly from qualtrics and what I want to do is create new columns Prob = 10 for QnF & Prob = 10 for QnM, Prob = 20 for QnF & Prob = 20 for QnM etc.
I want a code that recognises that in the first line the value of Prob=10 is associated with Q1F and Q1M as Prob 1 = 10, so then it would pull these values into my new columns Prob = 10 for QnF and Prob = 10 for QnM. Then it recognises that 30 is in Prob2, so it pulls the values from Q2F & Q2M into new columns Prob = 30 for QnF and Prob = 30 for QnM. SO the last 6 columns above are what I would like the ouput to be.

I have experience with creating tables and renaming values etc, just not sure how to do this count if kind of operation.

It is hard to explain so I hope this is clear. Many thanks and have a good day.

This topic was automatically closed 21 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.