set double

set_dbl(.data, ...)

# S3 method for character
set_dbl(.data, ...)

# S3 method for factor
set_dbl(.data, ...)

# S3 method for Date
set_dbl(.data, ...)

# S3 method for numeric
set_dbl(.data, ...)

# S3 method for integer64
set_dbl(.data, ...)

# S3 method for data.frame
set_dbl(.data, ...)

Arguments

.data

dataframe

...

tidyselect. Default selection: none

Value

tibble

Examples




date_col <- c(lubridate::ymd(20180101), lubridate::ymd(20210420))


tibble::tibble(int = c(1L, 2L),
fct = factor(c(10, 11)),
date = date_col,
chr = c("a2.1", "rtg50.5")) -> t1

t1
#> # A tibble: 2 × 4
#>     int fct   date       chr    
#>   <int> <fct> <date>     <chr>  
#> 1     1 10    2018-01-01 a2.1   
#> 2     2 11    2021-04-20 rtg50.5

t1 %>%
set_dbl(tidyselect::everything())
#> Registered S3 methods overwritten by 'readr':
#>   method                    from 
#>   as.data.frame.spec_tbl_df vroom
#>   as_tibble.spec_tbl_df     vroom
#>   format.col_spec           vroom
#>   print.col_spec            vroom
#>   print.collector           vroom
#>   print.date_names          vroom
#>   print.locale              vroom
#>   str.col_spec              vroom
#> # A tibble: 2 × 4
#>     int   fct     date   chr
#>   <dbl> <dbl>    <dbl> <dbl>
#> 1     1    10 20180101   2.1
#> 2     2    11 20210420  50.5

# s3 method works for vectors individually
# custom date coercion to represent date as a number. For lubridate's coercion method, use set_int
date_col %>%
set_dbl
#> [1] 20180101 20210420