How to deal with train test split where a factor variable has only 1 observation for some levels (Suggestions for tags welcome, could only think of r tag and predictive-models tag)
Here is a variable from my data:
> table(processed_train$cat89)

     A      B      C      D      E      F      G      H      I 
183744   4312    220     33      5      0      1      1      2 

I split my data into test and train, created a model and tried to do some prediction on test:
set.seed(123)
sample_train <- sample(nrow(processed_train),
                             floor(nrow(processed_train) * 0.8))
working_train <- processed_train[sample_train,]
working_test <- processed_train[-sample_train,]

# kitchen sink first model - all features
predictors <- names(subset(working_train, select = -c(id,target)))
model_mlr_sink <- lm(paste("loss ~ ",paste(predictors, collapse="+"),sep=""), data=working_train)

Before predicting, here is what a variable looks like:
> table(working_test$cat89)

    A     B     C     D     E     F     G     H     I 
73536  1697    78    12     3     0     1     0     1 
> table(processed_train$cat89)

     A      B      C      D      E      F      G      H      I 
183744   4312    220     33      5      0      1      1      2 

Now look what happens:
> prediction_mlr_sink <- predict(model_mlr_sink, interval="prediction", newdata=working_test)
Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : 
  factor cat89 has new levels G

From Googling around it seems the conventional wisdom is to just drop variable cat89. But that strikes me as crude. Is there a more elegant solution?
What should I do here in order to get my predictions on test data and avoid this error?
 A: It is indeed overkill to throw out the whole variable. Instead, I would combine the very rare levels into one level. Besides, individual dummy variables for such levels are very unlikely to have much predictive utility.
A: To elaborate on this answer:
What to do to fix this issue depends mostly on what exactly the variable means. The more uncommon levels (arguably all except for A) are not well represented in your dataset. There could be a couple of explainations for this, along with some fixes.
The biggest question is, how relevant is the distinction between the uncommon variables? For example, is it relevant for classification to know whether datapoint x belongs to group H or I? Maybe it is enough to know if it is in A, or not. An example for this is if the factors represent intervals for variable x: A = 0-10, B = 10-20, etc. If the higher values are uncommon, you could group them together as C = 20+.
So to elaborate on the answer of @Kodiologist, it might be beneficial to group some of the factors together. Maybe even go as far as to place them in groups A and Not A (whether this makes logical sense, depends on your dataset so it is up to you eventually).
Lastly, another thing to note is that in linear models, like you use, the individual factors of your variable are all (all but one) coded as different variables which happen to be mutually exclusive (Dummy variables). So if you have an individual variable that is 0 for all but one datapoint, it is unlikely that this will play any role in actually classifying reliably (without completely overfitting on that particular datapoint, that is).

So to recapitulate:
You have factors within a variable that are sparsely represented in your dataset. One of the offered options is to throw out all of the factors by removing the variable entirely. An alternative is to group the uncommon factors together. How you do this should depend on what the factors actually mean. 
