Mutate All Columns to Character
mutate_all_char(data)
data | A dataframe or tibble. |
---|
library(tidyverse) test_data <- tibble(A = sample(c(NA_integer_, 1:3), size = 10, replace = TRUE), B = sample(c(NA_integer_, 4:6), size = 10, replace = TRUE), C = sample(c(" apple ", "banana ", " orange", NA_character_), size = 10, replace = TRUE)) # Mutate all to character mutate_all_char(test_data)#> # A tibble: 10 x 3 #> A B C #> <chr> <chr> <chr> #> 1 3 5 " orange" #> 2 1 5 "banana " #> 3 1 4 "banana " #> 4 3 4 " orange" #> 5 3 NA NA #> 6 NA 6 "banana " #> 7 1 6 "banana " #> 8 NA 5 "banana " #> 9 1 6 " apple " #> 10 2 6 " apple "#> Error: Problem with `mutate()` input `C`. #> x unused argument (whitespace = whitespace) #> ℹ Input `C` is `(structure(function (..., .x = ..1, .y = ..2, . = ..1) ...`.#> Error: Problem with `mutate()` input `C`. #> x unused argument (whitespace = whitespace) #> ℹ Input `C` is `(structure(function (..., .x = ..1, .y = ..2, . = ..1) ...`.#> Error: Problem with `mutate()` input `C`. #> x unused argument (whitespace = whitespace) #> ℹ Input `C` is `(structure(function (..., .x = ..1, .y = ..2, . = ..1) ...`.