Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是一个简短的问题,但我如何在 R 中查找因子变量的维度?我试过了:
dim(X) nrow(X) ncol(X)
但都回来了NULL
NULL
如果我们有一个原子变量(一个因子是),它将有一个length值
length
X <- factor(letters) length(X) ## [1] 26
它也会有levels
levels
levels(x)
什么时候X是一个因素,它is有以下几类
X
is
is(X) [1] "factor" "integer" "oldClass" "numeric" "vector"
当一个人有一个数据框并且需要一次了解许多不同的级别时,str() 函数也很有帮助。