I want to control a linear regression model with a specific variable. If i assign variable "c" as 0, i want to estimate the model:
lm(y ~ x) # model with intercept
and if i assign variable "c" as 1 i want to estimate:
lm(y ~ x - 1) # model without intercept
I tried the code below
c <- 1
lm(y ~ x - c)
but it didn't work. c is 1 but in lm function i can't use this variable for argument. How can i assign and use a variable to add intercept and remove?