[R] cleanup/replacing a value on condition of another value
Dr Eberhard W Lisse
no@p@m @end|ng |rom ||@@e@NA
Tue Oct 26 22:59:00 CEST 2021
Thanks.
Your method
mutate(
cases = ifelse(
country == 'Namibia'
& type == 'confirmed'
& date == '2021-10-23'
& cases == 357,
NA,
cases
)
)
works, as does Rui's
mutate(
cases = replace(
cases,
which(country == 'Namibia'
& type == 'confirmed'
& date == '2021-10-23'
& cases == 357),
NA
)
)
Thank you both, again.
el
On 2021-10-25 23:14 , Avi Gross via R-help wrote:
> I wonder why it is not as simple as:
>
> Call mutate on the data and have a condition that looks like:
>
> data %>% mutate(cases = ifelse(multiple_cond, NA, cases) -> output
[...]
More information about the R-help
mailing list