【发布时间】:2023-03-22 12:37:01
【问题描述】:
这里又短又甜……
我在 R 中分析的数据框中有邮政编码。
R 将它们作为数字变量读取。如何让 R 将这些邮政编码(例如 20001)作为 categorical 变量读取。
【问题讨论】:
-
data$ZIP <- as.character(data$ZIP)或data$ZIP <- as.factor(data$ZIP),取决于您喜欢使用的变量类型
标签: r dataframe type-conversion numeric categorical-data