I have a data frame like this
df <- data.frame(letters=letters[1:5], numbers=seq(1:5))
and lets say that I want to extram the first column into a list
firstColumn <- df[,1]
> firstColumn[[1]]
[1] a
Levels: a b c d e
Problème is I want to remove the level to have a string
any help please ?
thanks
Either define your variable as character from the beginning :
df <- data.frame(letters=letters[1:5], numbers=seq(1:5), stringsAsFactors=FALSE)
Or convert it afterwards :
firstColumn <- as.character(df[,1])