"object not found" but object exists

I might be missing something super obvious here, but I'm trying to make a histogram and when I run the code it says "Error in hist(no_car) : object 'no_car' not found" even though I can run regressions and other functions just fine. I'm typing everything correctly but I'm not sure what I'm doing wrong.

Hello @mlind18 ,

show us the code you are using.

Error in hist(county_coded) : object 'county_coded' not found

I ran a regression with the same variable and had no trouble

Then redo your regression and do the hist immediately after the regression.

If you closed your R session after doing the regression and then start a new session
you have to recreate the variables you used (if you want to continue your analysis).

You can save and reload the contents of your workspace, but in general I think it is better to save the code that you use (as an R file) and rerun it when needed.

Just tried that, still no luck. Do i need to create the variables if they're in the dataset that I'm using?

i think i figured it out, i did this: > hist(transpo_times_Sheet1$county_coded) and it worked!

I think you did something like (using an example from here )

income.happiness.lm <- lm(happiness ~ income, data = income.data)

in that case your variable is a column of a data.frame and to plot it you could use

hist( income.data$happiness)

So in your case the name of the data.frame that you use followed by "$county_coded"

that worked thank you so much!!

That is good!

Now your problem is solved, indicate this in this issue.
Then other forum participants will see that they can skip this issue.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.