I have a data.frame
( df
) with column name v1
which is a factor
. Like:
df
# v1
# --
# a
# b
# c
When I want to get levels of the factor
I get:
By column name:
levels(df$v1)
# [1] "a" "b" "c"
By column number:
levels(df[1])
# NULL
Why do I get NULL
when I use column number.
Thanks a lot.
levels(df[,1])
[1] "a" "b" "c"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.