-1
I have a date.frame with many values with more than 2 houses after the comma, I would like to round to only 2 houses after the comma using preferably the operator %>%
, if possible, as this operation is very common in my study and would not like to generate intermediate data frames..
Be this piece of my date.frame with the column IQA
a<-read.table(text = "Estacao2 IQA Ano Ano2 Epoca
1 58.5 2005 2005-01-01 Chuvoso
1 61.5 2005 2005-01-01 Seca
10 73.5 2005 2005-01-01 Chuvoso
10 74.577 2005 2005-01-01 Seca
11 68.577 2005 2005-01-01 Chuvoso
11 69 2005 2005-01-01 Seca
12 69.566 2005 2005-01-01 Chuvoso
14 75.25 2005 2005-01-01 Seca
15 52.33333333 2005 2005-01-01 Chuvoso
15 65 2005 2005-01-01 Seca
16 77.37577 2005 2005-01-01 Chuvoso
16 76.375 2005 2005-01-01 Seca
17 52.28571429 2005 2005-01-01 Chuvoso
17 54.22 2005 2005-01-01 Seca
", sep="", header = TRUE)
a
Update: replace the commas with dots, I hadn’t realized it before.
Note that the conversion of
character
is simpler when compared to the one made withfactor
. Look at this reply not to be confused when this occurs.– neves
mutate(across(.cols = IQA, .fns = ~ round(x = as.numeric(.), 2)))
is execlent– wesleysc352