We're trying to clean up our data. We've collected the dataset and almost everything works, apart from the last bit of code. It says it can not find the function across.
The code is as follows:
cleandata <- data1 %>%
pivot_longer(3:173, names_to = "variable", values_to = "value") %>%
select(-2) %>%
mutate(year = as.numeric(str_extract(variable, "[0-9]{4}"))) %>%
mutate(variable = str_extract(variable, "(.+)
")) %>%
mutate(variable = str_replace(variable, "\r", "")) %>%
distinct() %>%
pivot_wider(names_from = variable, values_from = value) %>%
mutate(across(2:ncol(.), as.numeric))
It gives the following error:
Error in across(2:ncol(.), as.numeric) : could not find function "across"
Does someone have a solution to this problem?
See Question&Answers more detail:os