Struggling with the round function

I am trying to round all of the numeric values to a certain number of digits. I can get it to work with out setting the digits (so it just rounds to whole numbers), but I want to be able to set how many digits I am getting back. Any suggestions?

fdecteamstats=filter(decteamstats, Team == "Seattle U") %>%
  mutate_if(is.numeric, round(digits = 2))

The error I'm getting is:

Error: expecting a one sided formula, a function, or a function name.

You need to pass the value of the digits argument separately.

DF <- data.frame(Name = c("A", "B", "C"), Value = c(1.2345, 5.432345, 4.345645))
DF %>%  mutate_if(is.numeric, round, digits = 2)
  Name Value
1    A  1.23
2    B  5.43
3    C  4.35
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.