Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in `$<-.data.frame`(`*tmp*`, marital1, value = numeric(0)) : replacement has 0 rows, data has 526

Tags:

r

Have a CSV file with wages.

Attempting to convert a qualitative variable into a numerical variable. The variable is "marital", where 1 denotes being married and 0 denotes being unmarried.

wages = read.csv("Desktop/wages.csv")

wages$marital1=as.numeric(wages$marital1=="married")

Keep getting

Error in `$<-.data.frame`(`*tmp*`, marital1, value = numeric(0)) :
replacement has 0 rows, data has 526
like image 492
user13582101 Avatar asked Dec 01 '25 02:12

user13582101


1 Answers

You need to check your variable name (column name), the reason for this problem is usually because the variable name in your function is different from the variable name (column name) in the data frame.

like image 50
聂秀泉 Avatar answered Dec 02 '25 14:12

聂秀泉



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!