Q:

Why is the type of a character column a list?

Why is the type of the column created through map list? I would expect it to be a character column.  How can I convert it to a character column?
t <- mtcars %>% mutate(new_col=map(mpg, function(x) as.character(x)))
typeof(t$new_col)

> [1] "list"

Thanks

A:

You can use map_chr() instead of map().
And you can just write
mtcars %>% mutate(new_col = map_chr(mpg, as.character))

A:

The result of map was a list. It's not generally wise to add lists to dataframes, but it can be done. The other common mistake is to add the result of POSIXlt to a dataframe. Again it can be done but subsequent operations may fail. You could have just used the function:
> t <- mtcars %>% mutate(new_col=as.character(mpg))
> typeof(t$new_col)
[1] "character"

