R : R programming: perform function with switch functionality for each row based on different column

Published --