Increase number of digits after filtering data frame

After filter an data frame the number of digits decreasing .How to solve ?
Thanks

The stored precision of the data should not have changed. Can you provide and example?

C <- read_csv("D:/TEMP/OD/ATL218-R-08.06.2023.csv")
library(dplyr)
library(tidyverse)
C %>%
filter(OD25<=29.93) %>%
C
OD

: I attached some record from dataframe

d <- mtcars[1:5,1:5]
d$frac <- d$hp/d$disp
d
#>                    mpg cyl disp  hp drat      frac
#> Mazda RX4         21.0   6  160 110 3.90 0.6875000
#> Mazda RX4 Wag     21.0   6  160 110 3.90 0.6875000
#> Datsun 710        22.8   4  108  93 3.85 0.8611111
#> Hornet 4 Drive    21.4   6  258 110 3.08 0.4263566
#> Hornet Sportabout 18.7   8  360 175 3.15 0.4861111
options(digits = 3)
d
#>                    mpg cyl disp  hp drat  frac
#> Mazda RX4         21.0   6  160 110 3.90 0.688
#> Mazda RX4 Wag     21.0   6  160 110 3.90 0.688
#> Datsun 710        22.8   4  108  93 3.85 0.861
#> Hornet 4 Drive    21.4   6  258 110 3.08 0.426
#> Hornet Sportabout 18.7   8  360 175 3.15 0.486

Created on 2023-06-27 with reprex v2.0.2

options(digits = 3), doesn work when you filter dataframe .

Thanks any way

d <- mtcars[1:5,1:5]
d$frac <- d$hp/d$disp
d |> dplyr::filter(hp == 110)
#>                 mpg cyl disp  hp drat      frac
#> Mazda RX4      21.0   6  160 110 3.90 0.6875000
#> Mazda RX4 Wag  21.0   6  160 110 3.90 0.6875000
#> Hornet 4 Drive 21.4   6  258 110 3.08 0.4263566
options(digits = 3)
d |> dplyr::filter(hp == 110)
#>                 mpg cyl disp  hp drat  frac
#> Mazda RX4      21.0   6  160 110 3.90 0.688
#> Mazda RX4 Wag  21.0   6  160 110 3.90 0.688
#> Hornet 4 Drive 21.4   6  258 110 3.08 0.426

C <- read_csv("D:/TEMP/OD/ATL218-R-08.06.2023.csv")
library(dplyr)
library(tidyverse)
C %>%
filter(OD25<=29.93) %>%
C
OD

Below result
Filter

you made a data.frame into a tibble, printing is controlled by pillar; but this is purely representational, the underlying data is unchanged.

I don’t see that you used this. And remember that there is a fundamental difference between how something appears and what it is. Usually, it’s preferable to let the data express itself however comes naturally and reserve format work for plots and tables that will go out to the world for display.

This topic was automatically closed 42 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.