I have:
- a dataframe
DATA
containing many numeric columns with the names:X1, X2, X3, ...
(the number of columns is variable) - numeric vectors
start1, start2, start3, ...
(as many as the columns ofDATA
) andEnd1, End2, End3, ...
(as many as the columns ofDATA
)
I want to add a column called Result
to DATA
, where the nth element of Result: DATA$Result[n]
is TRUE if all the following conditions are true:
- nth value of
DATA$X1
is betweenstart1[n]
andEnd1[n]
and - nth value of
DATA$X2
is betweenstart2[n]
andEnd2[n]
and....
How can I do this?