[R] Factor vs character in a data.frame vs vector
John Kane
jrkrideau at yahoo.ca
Fri Jul 7 13:03:51 CEST 2017
This is not serious problem but I just wonder if someone can explain what is happening.
The same command within a dataframe is giving me a factor and as a plain vector is giving me a character. It's probably something simple that I have read and forgotten but I thought I'd ask.
Thanks
#================================================
dat1 <- data.frame(aa = letters[1:10])
str(dat1)
data.frame': 10 obs. of 1 variable:
$ aa....letters.1.10.: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10#=============================================================
bb = letters[1:10]
str(bb)
chr [1:10] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
#==============================================================
[[alternative HTML version deleted]]
More information about the R-help
mailing list