Skip to content

Instantly share code, notes, and snippets.

@kleinschmidt
Created January 28, 2015 14:38
Show Gist options
  • Save kleinschmidt/0ee3300550468f5b9729 to your computer and use it in GitHub Desktop.
Save kleinschmidt/0ee3300550468f5b9729 to your computer and use it in GitHub Desktop.
converting factor to character after rowwise()
library(dplyr)
data.frame(a=factor(c('10', '20', '30', '40'))) %>%
mutate(b=as.character(a)) %>%
rowwise() %>%
mutate(c=as.character(a)) %>%
str
Classes ‘rowwise_df’, ‘tbl_df’, ‘tbl’ and 'data.frame': 4 obs. of 3 variables:
$ a: Factor w/ 4 levels "10","20","30",..: 1 2 3 4
$ b: chr "10" "20" "30" "40"
$ c: chr "1" "2" "3" "4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment