有一份薪资的CSV文件。
试图将一个定性变量转换为数值变量。该变量是“婚姻状况”,其中1表示已婚,0表示未婚。
wages = read.csv("Desktop/wages.csv")
wages$marital1=as.numeric(wages$marital1=="married")
持续收到
Error in `$<-.data.frame`(`*tmp*`, marital1, value = numeric(0)) :
replacement has 0 rows, data has 526
$<-.data.frame
(*tmp*
, marital1, value = numeric(0)) 中出现错误: 替换行数为0,数据有526行。 - user13582101