I defined several dummy variables and I can see them in my dataset. However, when I try to run a regression model, R says that Error: object "my_variable" not found. I also used exists(my_variable)
and got the same error message. I checked for the spelling and it was not a problem.
I'd appreciate it if someone can help.
Asked
Active
Viewed 57 times
0

Pir
- 1
- 1
-
1It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. How are you running your regression model? Are you passing the right data source to your regression function? It's very hard to guess what's going on without seeing data and code. – MrFlick Jul 09 '21 at 05:35
1 Answers
1
First, when you use exists()
, you should put the variable in quotations (i.e., exists("my_variable")
).
Second, be sure that you set up your regression model properly. For example:
lm(response ~ predictor1 + predictor2 + predictor3 + ...,
data=my_variable)
Ultimately, you need to include some of your data via dput(head(my_variable))
, and the regression code.

AndrewGB
- 16,126
- 5
- 18
- 49