如何在 data.frame 中查找列的数据类型?
我正在使用下面的代码,这有意义吗?我得到正确的输出了吗?
for (f in feature.names) {
if (class(train[[f]]) == "character") {
count_c <- count_c + 1
}
if(class(train[[f]]) == "numeric"){
count_numeric <- count_numeric + 1
}
if(class(train[[f]]) == "logical"){
print(f)
print(unique(train[[feature.names[count_n]]]))
cat('\n')
count_logic <- count_logic + 1
}
if(class(train[[f]]) == "integer"){
count_int <- count_int + 1
}
count_n <- count_n + 1
}