Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in UseMethod("itoken")

Tags:

r

text2vec

I have a dataframe IRC_DF and I would like to create an iterator over input objects to vocabularies, for this I try to do like this :

it_train <- itoken(IRC_DF$Raison.Reco, preprocessor = prep_fun,
                   tokenizer = tok_fun, ids = IRC_DF$ID, progressbar = FALSE)

But I get this error :

Error in UseMethod("itoken") : 
  no applicable method for 'itoken' applied to an object of class "factor"

Any idea please?

like image 591
Datackatlon Avatar asked Mar 25 '26 17:03

Datackatlon


1 Answers

Use the function as.character() on IRC_DF$Raison.Reco before using it on itoken.

  IRC_DF$Raison.Reco <- as.character(IRC_DF$Raison.Reco)      

  it_train = itoken(IRC_DF$Raison.Reco, preprocessor = prep_fun, tokenizer = tok_fun, ids = IRC_DF$ID, progressbar = FALSE)
like image 86
selmane simahdi Avatar answered Mar 28 '26 06:03

selmane simahdi



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!