What I want to do is to make a condition for if there is a certain variable in linear model
Example. If there is a B in a linear model
model <- lm(Y ~ A + B + C)
I want to do something. I have used the summary function before to refer to R-squared.
summary(model)$r.squared
Probably I am looking for something like this
if (B %in% summary(model)$xxx)
or
if (B %in% summary(model)[xxx])
But I can't find xxx. Please help =)
Try this:
if ("B" %in% all.vars(formula(model))) ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With