Error in eval(expr, envir, enclos) : object not found

Don’t know why @Janos deleted his answer, but it’s correct: your data frame Train doesn’t have a column named pre. When you pass a formula and a data frame to a model-fitting function, the names in the formula have to refer to columns in the data frame. Your Train has columns called residual.sugar, total.sulfur, alcohol and quality. You need to change either your formula or … Read more

backward elimination in R

When comparing different submodels, it is necessary that they be fitted to the same set of data — otherwise the results just don’t make sense. (Consider the extreme situation where you have two predictors A and B, which are each measured on only half of your observations — then the model y~A+B will be fitted to all the data, but … Read more

In R formulas, why do I have to use the I() function on power terms, like y ~ I(x^3)

The tilde operator is actually a function that returns an unevaluated expression, a type of language object. The expression then gets interpreted by modeling functions in a manner that is different than the interpretation of operators operating on numeric objects. The issue here is how formulas and specifically the “+, “:”, and “^” operators in them are … Read more

Simple manual RMarkdown tables that look good in HTML, PDF and DOCX

Inspired by daroczig’s comments, especially the clue that pander translates to pandoc’s pipe syntax, I took a closer look at the pander documentation and found reference to cat. After some experimentation, I found the winner: This produces uniformly good looking tables in HTML, PDF and docx in my tests. Now I’m off to upvote daroczig on some other questions to … Read more

R – error “variable lengths differ”

This happens because in your first step you created a separate variable outside of your data frame, transLOT<-log(LengthofTimemin). When you remove a row from the data, transLOT is unchanged. Even worse than differing lengths, your data doesn’t line up any more – if the different lengths were ignored, your rows of data would be “off … Read more