所以让我们为我的问题制作一个虚拟数据框:
KK <- c("2", "2","2","2", "2")
KE <- c("21", "23","42","26", "662")
Ed <- c("8", "8","3","9", "8")
Dummy <- data.frame(KK, KE, Ed)
Dummy$Educ[which(Dummy$Ed==unique("8"))] = "12"
Dummy$Educ[which(Dummy$Ed==unique("9"))] = "90"
这工作得很好!
但是,当我对.csv文件中的主要数据集执行相同操作时,它不起作用,并且出现此错误消息。知道这可能是什么吗?
Error in `$<-.data.frame`(`*tmp*`, Education, value = c(12, 12, 12, 12, :
replacement has 25914 rows, data has 25939