I'm new to R (about 1 week) and have a question that I could not find an answer to. I have a data frame with about 100 columns that take on the following form:
x_1 x_2 x_3...x_50 y_1 y_2 y_3...y_50.
I need to check each x column for a value (say, "01") and if it exists in a row, extract the value from the corresponding y column. I can easily do this is SAS with the following code:
data want;
set have;
array x[50] x_1 - x_50;
array y[50] y_1 - y_50;
do i = 1 to 50;
if x[i] = "01" then value = y[i];
output;
end;
run;
Any suggestions?