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,
help@r-project.org
Subject: Re: [R] cleanup/replacing a value on condition of another value
Rui,
that works for me too, but is not what I need to do.
I want to make the 'cases' value for this particular country AND this
particular date AND this particular type AND this particul
Thank you very much,
'which' does the trick :-)-O
greetings, el
On 2021-10-25 19:06 , Rui Barradas wrote:
Hello,
Here is a pipe to replace based on the composite condition.
It uses ?base::replace with an integer index vector.
[...]
library(dplyr)
data(coronavirus, package = "coronavirus
Hello,
Here is a pipe to replace based on the composite condition.
It uses ?base::replace with an integer index vector.
In the end, filter is meant to show the changed value in context, remove
it and assign the data.frame or tibble back to the input to change the
original.
library(dplyr)
d
Rui,
that works for me too, but is not what I need to do.
I want to make the 'cases' value for this particular country AND this
particular date AND this particular type AND this particular value (ie
ALL conditions must be fulfilled) become NA so that the tibble would
change from
[...]
Hello,
The following works with me.
library(coronavirus)
library(dplyr)
data(coronavirus, package = "coronavirus")
#update_dataset(silence = FALSE)
coronavirus %>%
select(country, date, type, cases) %>%
filter(
country == 'Namibia',
date == '2021-10-23',
cases == 357
)
Ca
The tibble shows the 'date' column as type date but you are comparing
io a string.
Perhaps replace that piece by
date == as.Date("2021-10-23")
Not tested.
HTH,
Eric
On Mon, Oct 25, 2021 at 2:26 PM Dr Eberhard W Lisse wrote:
>
> Hi,
>
> I have data from JHU via the 'coronavirus' package which ha
Hi,
I have data from JHU via the 'coronavirus' package which has a value for
the confirmed cases for 2021-10-23 which differs drastically (357) from
what is reported in country (23).
# A tibble: 962 × 4
country date type cases
1 Namibi
8 matches
Mail list logo