我一直在使用美国-成人收入普查1994年的adult-data,我想根据教育情况筛选列。
我试过了:
subset(mydata,education == "HS-grad")通过将其保留为facotr并将其转换为字符
mydata$education <- as.character(mydata$education)但它们不起作用
mydata中的教育列结构:
$ education : Factor w/ 16 levels " 10th"," 11th",..: 10 12 2 10 13 7 12 13 10 16 ...发布于 2019-02-19 15:26:49
我尝试过使用以下方法,代码运行良好
data = read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data",
sep=",",header=F,col.names=c("age", "type_employer", "fnlwgt", "education",
"education_num","marital", "occupation", "relationship", "race","sex",
"capital_gain", "capital_loss", "hr_per_week","country", "income"),
fill=FALSE,strip.white=T)
str(data)
data1 <- subset(data,education == "HS-grad")https://stackoverflow.com/questions/54760242
复制相似问题