I had this following code that worked just fine before my R updated from version 4.0 to 4.1 note, this is all part of a helper function I've written for a piece of software I'm developing, and I've replaced things accordingly. Without context, this functionality seems meaningless, please dont focus on what the code appears to be trying to accomplish here.
input1 <- data.frame(a = as.numeric(c(0, NA, 0, 0, NA)),
b = as.factor(c("f", "f", NA, "f", NA)),
stringsAsFactors = FALSE)
input2 <- data.frame(a = as.numeric(1),
b = factor(c("m")),
c = factor(c("married")),
d = factor(c("AZ")),
e = as.character(0),
f = as.integer(59),
g = as.Date("2021-02-14"),
stringsAsFactors = FALSE
)
input2 <- input2 %>% dplyr::select( tidyselect::all_of( colnames(fake_data_) ) )
# error occurs here, in the second mutate
input1 %>%
dplyr::mutate(dplyr::across(.fns = as.character)) %>%
dplyr::mutate(dplyr::across( .cols = tidyselect::everything(),
.fns = ~eval(parse(text = paste0( "as.",
class( input2[[ dplyr::cur_column() ]]),
"(.)")))
))
I get error Error: Problem with `mutate()` input `..1`. i `..1 = dplyr::across(...)`. x 'list' object cannot be coerced to type 'double'
could someone help with this please, thanks in advance!