0

だから私はdata.frameを入れたenvを持っています

dtm <- DocumentTermMatrix(corpus) termCount = c(".94", ".96", ".98" ,".99") freqMatrix <- new.env() spam <- new.env() for (v in termCount){ # Remove sparse terms to get a managable number of terms. dtmEnv[[v]] <- removeSparseTerms(dtm, as.numeric(v)) # Convert the document term matrix to a standard matrix. freqMatrix[[v]] <- as.data.frame( as.matrix(dtmEnv[[v]])) # Normalize the frequency matrix: 0 if absent, 1 if present. spam[[v]] <- (freqMatrix[[v]] > 0) + 0 # Add 0 to convert from logical to int. }

ただし、データフレームからスライスを取得しようとすると、エラーが発生します

for (v in termCount){
  trainData <- (spam[[v]])[folds$subsets[folds$which != i], ]
  testData  <- (spam[[v]])[folds$subsets[folds$which == i], ]
 # ... more stuff hear ...
 }

spam[[v]] のエラー (#8 から) : 環境をサブセット化するための間違った引数

結果の精度を出力します。

私は何を間違っていますか?termCount の異なる値に対してこのような反復を行うよりクリーンな方法はありますか?

4

0 に答える 0