-3

After using tbl_df in dplyr I got an object where some columns have attribute of <dbl>. I wonder if there is any easy way to change these columns to <chr> using dplyr? Thanks.

alittleboy
  • 10,616
  • 23
  • 67
  • 107
  • 6
    The Hadleyverse hasn't renamed every base R function yet. Using `as.character(x)` should do the job quite well ;-) – Jaap Jun 15 '16 at 19:08
  • @ProcrastinatusMaximus Thanks, but it does not seem to work... Error: All select() inputs must resolve to integer column positions. The following do not: * as.character(x) – alittleboy Jun 15 '16 at 19:11
  • 2
    In that case it would be nice to include a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610) in your question. That makes it a lot easier to help you. – Jaap Jun 15 '16 at 19:12
  • 1
    You're mutating, not selecting: `mutate(some_column = as.character(some_column)` or `mutate_each(funs(as.character))` – alistaire Jun 15 '16 at 19:28
  • @alistaire Thank you! This is exactly what I need :) – alittleboy Jun 15 '16 at 19:37

1 Answers1

0

mutate(some_column = as.character(some_column) or mutate_each(funs(as.character)) will do the work. Thanks @alistaire.

alittleboy
  • 10,616
  • 23
  • 67
  • 107