How would I go about conditionally replacing an observation with NA?
| REGION MANAGER |
STATUS |
Address |
| Igor |
Closed |
Smith St |
| Helena |
Open |
Peters St |
| Igor |
Closed |
Elver St |
| Helena |
Open |
Brownburg St |
| Igor |
Open |
Edel St |
If the status is "Closed" I want to list the address as NA, conditionally. Would I use case_when? Or if_else?
I tried:
data <- data %>% if_else(STATUS == "Closed", Address == NA, Address == Address`)
but get this error:Error: condition must be a logical vector, not a tbl_df/tbl/data.frame object.
This is my goal:
| REGION MANAGER |
STATUS |
Address |
| Igor |
Closed |
NA |
| Helena |
Open |
Peters St |
| Igor |
Closed |
NA |
| Helena |
Open |
Brownburg St |
| Igor |
Open |
Edel St |
Thank you