Not understanding the reason for the error and solution to it

prod.preds <- predict(rf.cv.1, production.tokens.tfidf)
Error in eval(predvars, data, env) : object 'if.' not found
the column doesnt exist in training data thus the error .
how do i overcome this error. any new column name should not give the error and instead should ignore it and continue execution.

code reference taken from here

Hi @animeshsarraf! Welcome!

I'm afraid you'll need to supply some more info in order for helpers to be able to understand your problem. Most error messages are difficult to understand on their own without seeing all of the code that they depend on (not just the one line that threw the error). You seem to have made some alterations to the code example you linked to, so it would be clearer to see all of your code.

Can you try making a self-contained reproducible example that demonstrates your problem? This should be complete, runnable code with all the necessary library() calls and some sample data that causes the same errors (this can be a subset of your full data set, for instance). For more specific info on how to do all that, see the link! :grin: You might also want to take a look at this: FAQ: Tips for writing R-related questions

1 Like

Hi,
I have attached my file. I am afraid *I *cannot share my csv file .

The problem is that whenever some new tokens appear in the "test.token" its giving an error message. New words/tokens are likely to occur in test data ,so there should be some function to check that or may be ignore the tokens which dont match with those available in the "train.tokens".

Error message:

Error in eval(predvars, data, env) : object 'x' not found

(x : the new token found in the test.token)

(Attachment doubt.txt is missing)

Without a small reproducible example, as @jcblum mentioned, it's incredibly difficult (nigh impossible) to say what's going on. If it's a matter of privacy, you can create a dummy dataset that demonstrates the behaviour.

For pointers on making a reproducible example (aka a reprex) specific to the community site, check out the reprex FAQ.