Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.7k views
Welcome To Ask or Share your Answers For Others

1 Answer

The across function is still only available in the development version of dplyr, not on CRAN yet (reference). This leads to two options:

P.S. In future questions, consider providing a reproducible example.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...