Hello All - finally I was able to successfully run the code sent by FJCC (Thanks a lot) and got my desired dataset.
However, I have a question:
I was running this code:
visadsl <- vis |> filter(ACTARMCD %in% c("VEDOIV_VEDOSC", "VEDOIV_PSC")) |>
mutate(trtn = case_when(
ACTARMCD == "VEDOIV_VEDOSC" ~ 1,
ACTARMCD == "VEDOIV_PSC" ~ 2,
TRUE ~ NA #This line shouldn't be necessary because actarmcd should have only two values
and was getting this error:
! Problem while computing
trtn = case_when(...).
Caused by error in
I read that both mutate() and case_when() functions are available in dplyr package whick is a part of tidyverse package. But the code only ran successfully when I installed tidyverse package.
Any idea what could be the reason?