0
我與NLS數據workign並嘗試重新編寫性別變量,在這裏我把它稱爲從一開始女,現在我試着重新編碼以下錯誤作爲R數據幀時,試圖重新編碼的變量
1 Male
2 Female
0 No Information
我的代碼:
Error in `$<-.data.frame`(`*tmp*`, "female", value = numeric(0)) : replacement has 0 rows, data has 7120
任何S:
nlsy$female[ nlsy$female == 1 ] <- 0
nlsy$female[ nlsy$female == 2 ] <- 1
不過,我自R得到以下錯誤uggestions?
請使用'dput'顯示一個小例子。根據你顯示的數據,語法應該工作 – akrun
>輸入 function(x,file =「」,control = c(「keepNA」,「keepInteger」, 「showAttributes」)) { if(is.character (文件)) 如果(nzchar(文件)){ 文件< - 文件(文件, 「重量」) on.exit(接近(文件)) – krilee
} 別的文件< - 標準輸出() OPTS < - 。 deparseOpts(control) if(isS4(x)){cl class < for(n in methods ::。slotNames(clx)){ cat(「,」,n,「=」,file = file) 輸入(方法:: slot(x,n),file = file,control = control) } cat(「)\ n」,file = file) invisible() } else .Internal(dput(x,文件,opts)) } <字節代碼:0x000000000c2a5df8> <環境:命名空間:基> > – krilee