I am attempting to create a new column (C) that has TRUE/FALSE value.
There are a number of possible values for Column A, and each also has a TRUE/FALSE value shown in Column B.
For each value of column A, if at least one row is "TRUE" in column B, I want all of column C to be TRUE for that value. For example...
A B
1 TRUE
1 FALSE
1 FALSE
1 FALSE
2 TRUE
2 FALSE
2 FALSE
3 FALSE
3 FALSE
4 TRUE
4 FALSE
4 FALSE
The return that I want looks like:
A B C
1 TRUE TRUE
1 FALSE TRUE
1 FALSE TRUE
1 FALSE TRUE
2 TRUE TRUE
2 FALSE TRUE
2 FALSE TRUE
3 FALSE FALSE
3 FALSE FALSE
4 TRUE TRUE
4 FALSE TRUE
4 FALSE TRUE
The issue is that, while I could enter an ifelse statement to define TRUE/FALSE for each value in column A manually, I have upward of 100 different values in column A.
So, as stated: if at least one row is TRUE per value in column A, all rows for that value need to be defined as TRUE in column C.
I do not know how to get R to perform such an operation, and any advice would be very welcome.