I am getting the following error when calculating VIF on a small dataset in Rstudio. Could anyone help? I can provide more information on the dataset if needed.
"Error in as.vector(y) - mean(y) non-numeric argument to binary operator".
Dataset: 80 obs. and 15 variables (all variables are numeric)
Steps Followed:
   # 1. Determine correlation  
    library(corrplot)  
    cor.data <- cor(train)  
    corrplot(cor.data, method = 'color')  
    cor.data    
# 2. Build Model  
    model2 <- lm(Volume~., train)  
    summary(model2)  
# 3. Calculate VIF  
    library(VIF)  
    vif(model2) 
Here is a sample dataset with 20 obs.
train <- structure(list(Price = c(949, 2249.99, 399, 409.99, 1079.99, 
114.22, 379.99, 65.29, 119.99, 16.99, 6.55, 15, 52.5, 21.08, 
18.98, 3.6, 3.6, 174.99, 9.99, 670), X.5.Star.Reviews. = c(3, 
2, 3, 49, 58, 83, 11, 33, 16, 10, 21, 75, 10, 313, 349, 8, 11, 
170, 15, 20), X.4.Star.Reviews. = c(3, 1, 0, 19, 31, 30, 3, 19, 
9, 1, 2, 25, 8, 62, 118, 6, 5, 100, 12, 2), X.3.Star.Reviews. = c(2, 
0, 0, 8, 11, 10, 0, 12, 2, 1, 2, 6, 5, 13, 27, 3, 2, 23, 4, 4
), X.2.Star.Reviews. = c(0, 0, 0, 3, 7, 9, 0, 5, 0, 0, 4, 3, 
0, 8, 7, 2, 2, 20, 0, 2), X.1.Star.Reviews. = c(0, 0, 0, 9, 36, 
40, 1, 9, 2, 0, 15, 3, 1, 16, 5, 1, 1, 20, 4, 4), X.Positive.Service.Review.   = c(2, 
1, 1, 7, 7, 12, 3, 5, 2, 2, 2, 9, 2, 44, 57, 0, 0, 310, 3, 4), 
    X.Negative.Service.Review. = c(0, 0, 0, 8, 20, 5, 0, 3, 1, 
    0, 1, 2, 0, 3, 3, 0, 0, 6, 1, 3), X.Would.consumer.recommend.product. = c(0.9, 
    0.9, 0.9, 0.8, 0.7, 0.3, 0.9, 0.7, 0.8, 0.9, 0.5, 0.2, 0.8, 
    0.9, 0.9, 0.8, 0.8, 0.8, 0.8, 0.7), X.Shipping.Weight..lbs.. = c(25.8, 
    50, 17.4, 5.7, 7, 1.6, 7.3, 12, 1.8, 0.75, 1, 2.2, 1.1, 0.35, 
    0.6, 0.01, 0.01, 1.4, 0.4, 0.25), X.Product.Depth. = c(23.94, 
    35, 10.5, 15, 12.9, 5.8, 6.7, 7.9, 10.6, 10.7, 7.3, 21.3, 
    15.6, 5.7, 1.7, 11.5, 11.5, 13.8, 11.1, 5.8), X.Product.Width. = c(6.62, 
    31.75, 8.3, 9.9, 0.3, 4, 10.3, 6.7, 9.4, 13.1, 7, 1.8, 3, 
    3.5, 13.5, 8.5, 8.5, 8.2, 7.6, 1.4), X.Product.Height. = c(16.89, 
    19, 10.2, 1.3, 8.9, 1, 11.5, 2.2, 4.7, 0.6, 1.6, 7.8, 15, 
    8.3, 10.2, 0.4, 0.4, 0.4, 0.5, 7.8), X.Profit.margin. = c(0.15, 
    0.25, 0.08, 0.08, 0.09, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 
    0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.15), Volume = c(12, 
    8, 12, 196, 232, 332, 44, 132, 64, 40, 84, 300, 40, 1252, 
    1396, 32, 44, 680, 60, 80)), .Names = c("Price", "X.5.Star.Reviews.", 
"X.4.Star.Reviews.", "X.3.Star.Reviews.", "X.2.Star.Reviews.", 
"X.1.Star.Reviews.", "X.Positive.Service.Review.", "X.Negative.Service.Review.", 
"X.Would.consumer.recommend.product.", "X.Shipping.Weight..lbs..", 
"X.Product.Depth.", "X.Product.Width.", "X.Product.Height.", 
"X.Profit.margin.", "Volume"), row.names = c(NA, 20L), class = "data.frame")
 
     
     
    