Charecter to numeric: display all decimal places in a tibble

When I convert the character column to a numeric one in the example below, I do not see all the numbers. How can I display all the decimal places?

library(dplyr)
df <- tibble(
  x_as_character = c("0.1232456789", "0.9101112131415")
  ) %>% 
  mutate(x_as_numeric = as.numeric(x_as_character))
df
#> # A tibble: 2 x 2
#>   x_as_character  x_as_numeric
#>   <chr>                  <dbl>
#> 1 0.1232456789           0.123
#> 2 0.9101112131415        0.910

use print.data.frame(df) as suggested in Why do tibbles and data.frames display decimal places a bit differently? - #2 by danr

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
df <- tibble(
  x_as_character = c("0.1232456789", "0.9101112131415")
) %>% 
  mutate(x_as_numeric = as.numeric(x_as_character))
options(digits=15)
print.data.frame(df)
#>    x_as_character    x_as_numeric
#> 1    0.1232456789 0.1232456789000
#> 2 0.9101112131415 0.9101112131415

Created on 2022-02-27 by the reprex package (v2.0.1)

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.