Yesterday when I tried to use mutate() function to recode some values in a specific column, everything was fine.
But suddenly, I run these codes again today, it returns errors from the line with mutate() function:
Can't transform a data frame with duplicate names.
Backtrace:
- EVS_recode %>% mutate_at(c("C001"), ~na_if(., -1))
- dplyr::mutate_at(., c("C001"), ~na_if(., -1))
- dplyr:::mutate.data.frame(.tbl, !!!funs)
- dplyr:::mutate_cols(.data, ..., caller_env = caller_env())
- DataMask$new(.data, caller_env)
- dplyr:::initialize(...)
here are the codes I used which work perfectly yesterday
#recode the 1 in column C001 to be 5, 2 to be 4#
EVS_recode <- EVS_recode %>% mutate(C001= recode(C001, '1' = 5, '2'= 4))
#recode the -1,-2,-4,-5 values to be NA in column C001#
EVS_recode <- EVS_recode %>% mutate_at(c('C001'), ~na_if(.,-1))
EVS_recode <- EVS_recode %>% mutate_at(c('C001'), ~na_if(.,-2))
EVS_recode <- EVS_recode %>% mutate_at(c('C001'), ~na_if(.,-4))
EVS_recode <- EVS_recode %>% mutate_at(c('C001'), ~na_if(.,-5))
This is my first time to have such large scale of codes not working related to mutate().
Could someone help me or has the similar problem when using mutate() ?
Thanks for your time to read this! It would be very helpful if someone can give me a hint.