I have the following code outputting contiguously until I print Variable Importance. At this point output appears in a new output box. Why? I want the output to appear as if I sinked plus of course the comments. It makes for a very readable output. Can someone explain this and what can I do to get output in one output screen?
model <- as.formula("y~z+x1+x2+x3+x4+x5+x6+x7+x8+x9+x10+x11")
model
# Model fits
# lm rsquare statistics
fit.obj <- lm(model, data=df2)
fit.obj
summary(fit.obj)
# glm deviance statistics
fit.obj <- glm(model, data=df2)
#fit.obj
# Variance Inflation
suppressMessages(library(car))
mod_vif <- vif(fit.obj)
cat("\n","VIF statistics")
cat("\n", "minimum:", min(mod_vif), "\n","max:", max(mod_vif), "\n","\n")
mod_vif
# Variable Importance
suppressMessages(library(caret))
cat("\n","Variable Importance")
temp <- as.data.frame(varImp(fit.obj))
feature <- row.names(temp)
temp2 <- cbind(feature,temp)
importance <- temp2[order(-temp2$Overall),]
importance
OUTPUT
y ~ z + x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11
Call:
lm(formula = model, data = df2)
Coefficients:
(Intercept) z x1 x2 x3 x4 x5
104.751754 -0.361332 0.085066 -1.492406 -0.062621 0.062437 -0.757251
x6 x7 x8 x9 x10 x11
0.004937 -0.001403 -103.909624 0.498756 0.721744 0.222670
Call:
lm(formula = model, data = df2)
Residuals:
Min 1Q Median 3Q Max
-3.7796 -0.4671 -0.0444 0.4561 3.0211
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 104.7517544 14.1355399 7.411 0.000000000000142 ***
...
VIF statistics
minimum: 1.555807
max: 22.33722
z x1 x2 x3 x4 x5 x6 x7 x8
7.224467 5.048348 2.168159 1.622151 9.634653 1.659342 2.235693 4.045899 22.337223
x9 x10 x11
2.563776 1.555807 5.616857
Variable Importance