Skip to contents

Coerce all columns to type character

Usage

columns_to_character(data)

Arguments

data

<data.frame>

Value

<data.frame> with columns coerced to character

See also

Examples

(x <- dplyr::tibble(int = c(1:9, NA_integer_), chr = letters[1:10], date = Sys.Date()))
#> # A tibble: 10 × 3
#>      int chr   date      
#>    <int> <chr> <date>    
#>  1     1 a     2025-01-02
#>  2     2 b     2025-01-02
#>  3     3 c     2025-01-02
#>  4     4 d     2025-01-02
#>  5     5 e     2025-01-02
#>  6     6 f     2025-01-02
#>  7     7 g     2025-01-02
#>  8     8 h     2025-01-02
#>  9     9 i     2025-01-02
#> 10    NA j     2025-01-02

columns_to_character(x)
#> # A tibble: 10 × 3
#>    int   chr   date      
#>    <chr> <chr> <chr>     
#>  1 1     a     2025-01-02
#>  2 2     b     2025-01-02
#>  3 3     c     2025-01-02
#>  4 4     d     2025-01-02
#>  5 5     e     2025-01-02
#>  6 6     f     2025-01-02
#>  7 7     g     2025-01-02
#>  8 8     h     2025-01-02
#>  9 9     i     2025-01-02
#> 10 NA    j     2025-01-02